本文整理汇总了C++中QMenuBar::actionGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::actionGeometry方法的具体用法?C++ QMenuBar::actionGeometry怎么用?C++ QMenuBar::actionGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::actionGeometry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseActivation
void tst_QMenu::mouseActivation()
{
QWidget topLevel;
QMenu menu(&topLevel);
topLevel.show();
menu.addAction("Menu Action");
menu.show();
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
//context menus can always be accessed with right click except on windows
menu.show();
QTest::mouseClick(&menu, Qt::RightButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
#ifdef Q_OS_WIN
//on windows normal mainwindow menus Can only be accessed with left mouse button
QMenuBar menubar;
QMenu submenu("Menu");
submenu.addAction("action");
QAction *action = menubar.addMenu(&submenu);
menubar.show();
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300);
QVERIFY(!submenu.isVisible());
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::RightButton, 0, QPoint(5, 5), 300);
QVERIFY(submenu.isVisible());
#endif
}
示例2: mouseActivation
void tst_QMenu::mouseActivation()
{
#ifdef Q_OS_WINCE_WM
QSKIP("We have a separate mouseActivation test for Windows mobile.", SkipAll);
#endif
QMenu menu;
menu.addAction("Menu Action");
menu.show();
QTest::mouseClick(&menu, Qt::LeftButton, 0, QPoint(5, 5), 300);
QVERIFY(!menu.isVisible());
//context menus can allways be accessed with right click except on windows
menu.show();
QTest::mouseClick(&menu, Qt::RightButton, 0, QPoint(5, 5), 300);
QVERIFY(!menu.isVisible());
#ifdef Q_OS_WIN
//on windows normal mainwindow menus Can only be accessed with left mouse button
QMenuBar menubar;
QMenu submenu("Menu");
submenu.addAction("action");
QAction *action = menubar.addMenu(&submenu);
menubar.show();
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300);
QVERIFY(!submenu.isVisible());
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::RightButton, 0, QPoint(5, 5), 300);
QVERIFY(submenu.isVisible());
#endif
}
示例3: activateMenu
void Utils::activateMenu(QMenu *menu) noexcept
{
if (menu == nullptr) {
throwScriptException(tr("Utils::activateMenu: (menu == nullptr). Given menu does not exist."));
return;
}
QMenuBar *menubar = dynamic_cast<QMenuBar *>(menu->parentWidget());
if (menubar == nullptr) {
throwScriptException(tr("Utils::activateMenu: (menubar == nullptr). Menubar does not exist."));
return;
}
const QPoint centerPoint = menubar->actionGeometry(menu->menuAction()).center();
QTest::mouseClick(menubar, Qt::LeftButton, Qt::NoModifier
, centerPoint);
mVirtualCursor.moveToXY(centerPoint.x(), centerPoint.y(), 50);
QTest::qWait(50);
if (!menu->activeAction()) {
QTest::keyClick(menu, Qt::Key_Down);
}
}