Problem with creating options menu on S60 device using Qt
I want to create standard native options menu which shows after pushing Options soft key on Nokia E52. It something similar to this one:
My code look like that:
this->changefile = menu开发者_运维技巧Bar()->addAction(tr("Change file"),this,SLOT(openFileChooser()));
this->changefile->setEnabled(true);
Problem is that when I push the button which should show this menu nothing happens. There is no menu. What is wrong with my code? Please help.
Here's how I create a softkey menu:
//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() ) );
Remember that the widget which has the menu has to be an active top-level widget for the menu to show.
Best regards
精彩评论