本文整理汇总了C++中QMenu::setToolTipsVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::setToolTipsVisible方法的具体用法?C++ QMenu::setToolTipsVisible怎么用?C++ QMenu::setToolTipsVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::setToolTipsVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initCopyAsMenu
void VMdEditor::initCopyAsMenu(QAction *p_before, QMenu *p_menu)
{
QStringList targets = g_webUtils->getCopyTargetsName();
if (targets.isEmpty()) {
return;
}
QMenu *subMenu = new QMenu(tr("Copy HTML As"), p_menu);
subMenu->setToolTipsVisible(true);
for (auto const & target : targets) {
QAction *act = new QAction(target, subMenu);
act->setData(target);
act->setToolTip(tr("Copy selected content as HTML using rules specified by target %1").arg(target));
subMenu->addAction(act);
}
connect(subMenu, &QMenu::triggered,
this, &VMdEditor::handleCopyAsAction);
QAction *menuAct = p_menu->insertMenu(p_before, subMenu);
if (p_before) {
p_menu->removeAction(p_before);
p_menu->insertAction(menuAct, p_before);
p_menu->insertSeparator(menuAct);
}
}
示例2: contextMenuEvent
void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
{
QMenu *menu = createStandardContextMenu();
menu->setToolTipsVisible(true);
VEditTab *editTab = dynamic_cast<VEditTab *>(parent());
Q_ASSERT(editTab);
if (editTab->isEditMode()) {
const QList<QAction *> actions = menu->actions();
if (textCursor().hasSelection()) {
initCopyAsMenu(actions.isEmpty() ? NULL : actions.last(), menu);
} else {
QAction *saveExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/save_exit.svg"),
tr("&Save Changes And Read"),
menu);
saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
connect(saveExitAct, &QAction::triggered,
this, [this]() {
emit m_object->saveAndRead();
});
QAction *discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
tr("&Discard Changes And Read"),
menu);
discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
connect(discardExitAct, &QAction::triggered,
this, [this]() {
emit m_object->discardAndRead();
});
menu->insertAction(actions.isEmpty() ? NULL : actions[0], discardExitAct);
menu->insertAction(discardExitAct, saveExitAct);
}
if (!actions.isEmpty()) {
menu->insertSeparator(actions[0]);
}
}
menu->exec(p_event->globalPos());
delete menu;
}