1

Nokia E52 で Options ソフ​​トキーを押した後に表示される標準のネイティブ オプション メニューを作成したいと考えています。これに似たもの:

メニュー

私のコードは次のようになります。

this->changefile = menuBar()->addAction(tr("Change file"),this,SLOT(openFileChooser()));
this->changefile->setEnabled(true);

問題は、このメニューを表示するボタンを押しても何も起こらないことです。メニューはありません。コードの何が問題になっていますか? 助けてください。

4

1 に答える 1

2

ソフトキー メニューの作成方法は次のとおりです。

//Create the action and set its softkey role
leftKeyAction_mp = new QAction( this );
leftKeyAction_mp->setText( "Options" );
leftKeyAction_mp->setSoftKeyRole( QAction::PositiveSoftKey );

//Add the action to the widget (QWidget::addAction)
addAction( leftKeyAction_mp );

//Create the menu and add set it for the action
optionsMenu_mp = new QMenu( this );
leftKeyAction_mp->setMenu( optionsMenu_mp );

//Add an action to the menu
optionsMenu_mp->addAction( "Item", this, SLOT( itemClicked() ) );

メニューを表示するには、メニューを持つウィジェットがアクティブな最上位のウィジェットでなければならないことに注意してください。

よろしくお願いします

于 2011-06-25T12:47:29.677 に答える