本文整理汇总了C++中QMenu::height方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::height方法的具体用法?C++ QMenu::height怎么用?C++ QMenu::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testContextMenu
void FlameGraphViewTest::testContextMenu()
{
int targetWidth = 0;
int targetHeight = 0;
{
QMenu testMenu;
testMenu.addActions(QmlProfilerTool::profilerContextMenuActions());
testMenu.addSeparator();
testMenu.show();
QTest::qWaitForWindowExposed(testMenu.window());
targetWidth = testMenu.width() / 2;
int prevHeight = testMenu.height();
QAction dummy(QString("target"), this);
testMenu.addAction(&dummy);
targetHeight = (testMenu.height() + prevHeight) / 2;
}
QTimer timer;
timer.setInterval(50);
timer.start();
connect(&timer, &QTimer::timeout, this, [&]() {
auto activePopup = qApp->activePopupWidget();
if (!activePopup || !activePopup->windowHandle()->isExposed())
return;
QTest::mouseMove(activePopup, QPoint(targetWidth, targetHeight));
QTest::mouseClick(activePopup, Qt::LeftButton, Qt::NoModifier,
QPoint(targetWidth, targetHeight));
if (!manager.isRestrictedToRange()) {
// click somewhere else to remove the menu and return to outer function
QTest::mouseClick(qApp->activePopupWidget(), Qt::LeftButton, Qt::NoModifier,
QPoint(500, 500));
}
});
QTest::mouseMove(&view, QPoint(250, 250));
QSignalSpy spy(&view, SIGNAL(showFullRange()));
QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(250, 250));
QVERIFY(qApp->notify(&view, &event));
QCOMPARE(spy.count(), 0);
manager.restrictToRange(1, 10);
QVERIFY(qApp->notify(&view, &event));
if (spy.count() != 1)
QTRY_COMPARE(spy.count(), 1);
}
示例2: init
bool ApplicationsMenuApplet::init(QWidget* parent)
{
if(m_settings.type() == QVariant::List)
{
QVariantList list = m_settings.value<QVariantList>();
while(!list.isEmpty())
{
const char** names = reinterpret_cast<const char**>(list.takeFirst().value<void*>());
QMenu* menu = m_menu->addMenu(g_menu_names.value(names[0]));
menu->setIcon(QIcon::fromTheme(names[1]).pixmap(menu->height(),menu->height()));
m_menus.insert(g_menu_names.value(names[0]), menu);
}
QStringList categories;
for(QList<DesktopEntryObject*>::iterator pos = m_entries.begin(); pos != m_entries.end(); ++pos)
{
if(m_menus.contains((*pos)->Category()))
m_menus[(*pos)->Category()]->addAction((*pos)->Action());
else
m_menus["Other"]->addAction((*pos)->Action());
/*
categories = (*pos)->Categories();
for(QStringList::iterator pos2 = categories.begin(); pos2 != categories.end(); ++pos2)
if(m_menus.contains(*pos2))
m_menus[*pos2]->addAction((*pos)->Action());
*/
}
}
m_menu->addSeparator();
m_menu->addAction(QIcon::fromTheme("application-exit"), "Quit", qApp, SLOT(quit()));
/*
connect(DesktopApplications::instance(), SIGNAL(applicationUpdated(const DesktopApplication&)), this, SLOT(onApplicationUpdated(const DesktopApplication&)));
connect(DesktopApplications::instance(), SIGNAL(applicationRemoved(const QString&)), this, SLOT(onApplicationRemoved(const QString&)));
QList<DesktopApplication> apps = DesktopApplications::instance()->applications();
foreach(const DesktopApplication& app, apps)
onApplicationUpdated(app);
*/
return true;
}