【问题标题】:Problem with creating options menu on S60 device using Qt使用 Qt 在 S60 设备上创建选项菜单的问题
【发布时间】:2011-06-25 11:48:11
【问题描述】:

我想创建标准的原生选项菜单,该菜单在诺基亚 E52 上按选项软键后显示。 它类似于这个:

我的代码是这样的:

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

问题是当我按下应该显示此菜单的按钮时,什么也没有发生。没有菜单。我的代码有什么问题?请帮忙。

【问题讨论】:

  • 您是否在模拟器上运行您的应用程序?我使用 Qt Creator 2.0.1,如果我在模拟器上运行我的应用程序,选项菜单不会弹出。但是在设备上它工作得很好。

标签: qt menu symbian s60


【解决方案1】:

以下是我创建软键菜单的方法:

//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() ) );

请记住,具有菜单的小部件必须是活动的顶级小部件才能显示菜单。

最好的问候

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 2012-08-08
    • 2012-03-11
    • 2018-08-12
    • 2021-07-02
    相关资源
    最近更新 更多