本文整理汇总了C++中QMenu::insertActions方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::insertActions方法的具体用法?C++ QMenu::insertActions怎么用?C++ QMenu::insertActions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::insertActions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddMenus
void MainWindowMenuManager::AddMenus (const QMap<QString, QList<QAction*>>& menus)
{
for (const auto& menuName : menus.keys ())
{
QMenu *toInsert = nullptr;
if (menuName == "view")
toInsert = MenuView_;
else if (menuName == "tools")
toInsert = MenuTools_;
else
for (auto action : Menu_->actions ())
if (action->menu () &&
action->text () == menuName)
{
toInsert = action->menu ();
break;
}
const auto& actions = menus [menuName];
if (toInsert)
toInsert->insertActions (toInsert->actions ().value (0, 0), actions);
else
{
auto menu = new QMenu { menuName, Menu_.get () };
menu->addActions (actions);
Menu_->insertMenu (MenuTools_->menuAction (), menu);
}
IconThemeEngine::Instance ().UpdateIconset (actions);
}
}
示例2: contextMenuEvent
void ActionLineEdit::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = createStandardContextMenu();
if (actions().count() > 0) {
QAction *before = NULL;
if (menu->actions().count() > 0) {
before = menu->actions().first();
}
menu->insertActions(before, actions());
menu->insertSeparator(before);
}
menu->exec(e->globalPos());
delete menu;
}
示例3: createActions
void ProjectManager::createActions()
{
newProjectAct = new QAction(tr("New Project"),this);
newProjectAct->setToolTip(tr("Create New Project"));
connect(newProjectAct,SIGNAL(triggered()),this,SLOT(newProject()));
openProjectAct = new QAction(tr("Open Project"),this);
openProjectAct->setToolTip(tr("Open Project"));
connect(openProjectAct,SIGNAL(triggered()),this,SLOT(openProject()));
closeProjectAct = new QAction(tr("Close Project"),this);
closeProjectAct->setToolTip(tr("Close Project"));
connect(closeProjectAct,SIGNAL(triggered()),this,SLOT(closeProject()));
QMenu *fileMenu = liteApp->mainWindow()->fileMenu();
QAction *seperator = fileMenu->insertSeparator(fileMenu->actions()[0]);
fileMenu->insertActions(seperator,QList<QAction*>() << newProjectAct
<< openProjectAct << closeProjectAct);
}
示例4: insertActions
void QMenuProto::insertActions(QAction *before, QList<QAction *>actions)
{
QMenu *item = qscriptvalue_cast<QMenu*>(thisObject());
if (item)
item->insertActions(before, actions);
}