1

I want to create standard native options menu which shows after pushing Options soft key on Nokia E52. It something similar to this one:

menu

My code look like that:

this->changefile = menuBar()->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.

pchot
  • 380
  • 3
  • 14
  • 1
    Do you run your app on simulator? I use Qt Creator 2.0.1 and if I run my app on simulator the Options menu doesn't pop up. However on a device it works perfectly fine. – Yuliya Jun 27 '11 at 20:02

1 Answers1

2

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

Gerstmann
  • 5,368
  • 6
  • 37
  • 57