使用Qt在S60设备上创建选项菜单时出现问题

问题描述

| 我想创建标准的本机选项菜单,该菜单在按诺基亚E52上的“选项”功能键后显示。 它与此类似: 我的代码如下所示:
this->changefile = menuBar()->addAction(tr(\"Change file\"),this,SLOT(openFileChooser()));
this->changefile->setEnabled(true);
问题是,当我按下应该显示此菜单的按钮时,什么也没有发生。没有菜单。我的代码有什么问题?请帮忙。     

解决方法

        这是我创建软键菜单的方式:
//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() ) );
请记住,具有菜单的小部件必须是活动的顶层小部件,菜单才能显示。 最好的祝福     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...