
我在底部创建并显示了一个带有软键选项的QWebView。当我点击“选项”,一个菜单出现,但它是小的,黑色的,在左上角(它应该看起来像标准的蓝色软键,并在它们的正上方)。我关注了这个example。
//create webview
webView = new QWebView;
webView->setUrl(QString(":html/internal.html"));
//create menu
QAction *option1 = new QAction(tr("Back"), webView);
option1->setSoftKeyRole(QAction::PositiveSoftKey);
connect(option1, SIGNAL(triggered()), this, SLOT(deleteView()));
//create right softkey action to launch the "options" menu
QAction *option2 = new QAction(tr("Options"), webView);
option2->setSoftKeyRole(QAction::NegativeSoftKey);
connect(option2, SIGNAL(triggered(), this, SLOT(showMenu()));
QMenu *menuOptions = new QMenu(webView);
menuOptions->addAction(tr("Sub Menu 1"), this, SLOT(aboutView()));
menuOptions->addAction(tr("Sub Menu 2"), this, SLOT(aboutView()));
option2->setMenu(menuOptions);
//add softkey menus
QList < QAction* > softKeys;
softKeys.append(option1);
softKeys.append(option2);
webView->addActions(softKeys);
webView->show();发布于 2010-12-28 15:40:31
This example在模拟器和手机上都工作得很好。从Qt 4.6.x开始,它包含在QTDIR/examples/widgets文件夹中
https://stackoverflow.com/questions/4485547
复制相似问题