当前位置: 首页>>代码示例>>C++>>正文


C++ QMenuBar::actionGeometry方法代码示例

本文整理汇总了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
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例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
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:35,代码来源:tst_qmenu.cpp

示例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);
	}
}
开发者ID:Kirill-NiK,项目名称:qreal,代码行数:22,代码来源:utils.cpp


注:本文中的QMenuBar::actionGeometry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。