本文整理汇总了C++中QAction::setMenuRole方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setMenuRole方法的具体用法?C++ QAction::setMenuRole怎么用?C++ QAction::setMenuRole使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setMenuRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createHelpMenu
void MainWindow::createHelpMenu()
{
// Help menu
QAction* manualAct = new QAction(QIcon(QString::fromLatin1(":/images/help.png")), tr("Open &Manual"), this);
manualAct->setStatusTip(tr("Show the help file for this application"));
manualAct->setShortcut(QKeySequence::HelpContents);
connect(manualAct, &QAction::triggered, this, &MainWindow::showHelp);
QAction* aboutAct = new QAction(tr("&About %1").arg(appName()), this);
aboutAct->setStatusTip(tr("Show information about this application"));
aboutAct->setMenuRole(QAction::AboutRole);
connect(aboutAct, &QAction::triggered, this, &MainWindow::showAbout);
QAction* aboutQtAct = new QAction(tr("About &Qt"), this);
aboutQtAct->setStatusTip(tr("Show information about Qt"));
aboutQtAct->setMenuRole(QAction::AboutQtRole);
connect(aboutQtAct, &QAction::triggered, qApp, QApplication::aboutQt);
if (show_menu)
{
QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(manualAct);
helpMenu->addAction(QWhatsThis::createAction(this));
helpMenu->addSeparator();
helpMenu->addAction(aboutAct);
helpMenu->addAction(aboutQtAct);
}
}
示例2: addAction
QAction* CWizActions::addAction(WIZACTION& action)
{
QString strText = action.strText;
QString strIconName = action.strName;
QString strShortcut = action.strShortcut;
QString strSlot = "1on_" + action.strName + "_triggered()";
QAction* pAction = new QAction(strText, m_parent);
if (!strIconName.isEmpty()) {
pAction->setIcon(::WizLoadSkinIcon(m_app.userSettings().skin(), QColor(0xff, 0xff, 0xff), strIconName));
}
if (!strShortcut.isEmpty()) {
pAction->setShortcut(QKeySequence(strShortcut));
}
if (action.strName == "actionAbout")
pAction->setMenuRole(QAction::AboutRole);
else if (action.strName == "actionPreference")
pAction->setMenuRole(QAction::PreferencesRole);
else if (action.strName == "actionExit")
pAction->setMenuRole(QAction::QuitRole);
// Used for building menu from ini file
pAction->setObjectName(action.strName);
m_actions[action.strName] = pAction;
QObject::connect(pAction, "2triggered()", m_parent, strSlot.toUtf8());
return pAction;
}
示例3: QMainWindow
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *quitAction = fileMenu->addAction(tr("&Quit"), this, SLOT(close()));
quitAction->setShortcut(QKeySequence::Quit);
quitAction->setMenuRole(QAction::QuitRole);
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
QAction *aboutAction = helpMenu->addAction(tr("&About"));
aboutAction->setMenuRole(QAction::AboutRole);
QObject::connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
QAction *aboutQtAction = helpMenu->addAction(tr("About &Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
QObject::connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
tabWidget = new QTabWidget;
setCentralWidget(tabWidget);
sessionBusViewer = new QDBusViewer(QDBusConnection::sessionBus());
systemBusViewer = new QDBusViewer(QDBusConnection::systemBus());
tabWidget->addTab(sessionBusViewer, tr("Session Bus"));
tabWidget->addTab(systemBusViewer, tr("System Bus"));
restoreSettings();
}
示例4: switch
QAction *BApplicationPrivate::createStandardAction(BGuiTools::StandardAction type, QObject *parent)
{
if (!testInit("BApplicationPrivate"))
return 0;
QAction *act = 0;
switch (type) {
case BGuiTools::SettingsAction:
act = new QAction(parent);
act->setMenuRole(QAction::PreferencesRole);
act->setObjectName("ActionSettings");
act->setIcon(BApplication::icon("configure"));
act->setShortcut(QKeySequence::Preferences);
connect(act, SIGNAL(triggered()), qs_func(), SLOT(showSettingsDialog()));
break;
case BGuiTools::HomepageAction:
act = new QAction(parent);
act->setObjectName("ActionHomepage");
act->setIcon(BApplication::icon("gohome"));
connect(act, SIGNAL(triggered()), qs_func(), SLOT(openHomepage()));
break;
case BGuiTools::HelpContentsAction:
act = new QAction(parent);
act->setObjectName("ActionHelpContents");
act->setIcon(BApplication::beqtIcon("help_contents"));
connect(act, SIGNAL(triggered()), qs_func(), SLOT(showHelpContents()));
break;
case BGuiTools::ContextualHelpAction:
act = new QAction(parent);
act->setObjectName("ActionContextualHelp");
act->setIcon(BApplication::icon("help_contextual"));
connect(act, SIGNAL(triggered()), qs_func(), SLOT(showContextualHelp()));
break;
case BGuiTools::WhatsThisAction:
act = QWhatsThis::createAction(parent);
act->setObjectName("ActionWhatsThis");
act->setIcon(BApplication::beqtIcon("help_hint"));
break;
case BGuiTools::AboutAction:
act = new QAction(parent);
act->setMenuRole(QAction::AboutRole);
act->setObjectName("ActionAbout");
act->setIcon(BApplication::icon("help_about"));
connect(act, SIGNAL(triggered()), qs_func(), SLOT(showAboutDialog()));
break;
default:
return 0;
}
act->setProperty("beqt/standard_action_type", type);
qs_func()->ds_func()->actions.insert(act, act);
connect(act, SIGNAL(destroyed(QObject *)), qs_func()->ds_func(), SLOT(actionDestroyed(QObject *)));
retranslateStandardAction(act);
return act;
}
示例5: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow mw;
#ifndef Q_OS_MAC
app.setWindowIcon(QIcon(QLatin1String(":/qt-project.org/qdbusviewer/images/qdbusviewer.png")));
#else
mw.setWindowTitle(qApp->translate("QtDBusViewer", "Qt D-Bus Viewer"));
#endif
QTabWidget *mainWidget = new QTabWidget;
mw.setCentralWidget(mainWidget);
QDBusViewer *sessionBusViewer = new QDBusViewer(QDBusConnection::sessionBus());
QDBusViewer *systemBusViewer = new QDBusViewer(QDBusConnection::systemBus());
mainWidget->addTab(sessionBusViewer, QObject::tr("Session Bus"));
mainWidget->addTab(systemBusViewer, QObject::tr("System Bus"));
QStringList args = app.arguments();
while (args.count()) {
QString arg = args.takeFirst();
if (arg == QLatin1String("--bus")) {
QDBusConnection connection = QDBusConnection::connectToBus(args.takeFirst(), "QDBusViewer");
if (connection.isConnected()) {
QDBusViewer *customBusViewer = new QDBusViewer(connection);
mainWidget->addTab(customBusViewer, QObject::tr("Custom Bus"));
}
}
}
QMenu *fileMenu = mw.menuBar()->addMenu(QObject::tr("&File"));
QAction *quitAction = fileMenu->addAction(QObject::tr("&Quit"), &mw, SLOT(close()));
quitAction->setShortcut(QKeySequence::Quit);
quitAction->setMenuRole(QAction::QuitRole);
QMenu *helpMenu = mw.menuBar()->addMenu(QObject::tr("&Help"));
QAction *aboutAction = helpMenu->addAction(QObject::tr("&About"));
aboutAction->setMenuRole(QAction::AboutRole);
QObject::connect(aboutAction, SIGNAL(triggered()), sessionBusViewer, SLOT(about()));
QAction *aboutQtAction = helpMenu->addAction(QObject::tr("About &Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
QObject::connect(aboutQtAction, SIGNAL(triggered()), &app, SLOT(aboutQt()));
mw.show();
return app.exec();
}
示例6: toQAction
QAction* ActionResource::toQAction() const {
Log log( Log::LT_TRACE, Log::MOD_MAIN, "QAction* ActionResource::toQAction() const" );
if( !( m_Type == AT_ITEM || m_Type == AT_SEPARATOR ) ) {
return NULL;
};
log.write( Log::LT_TRACE, "Produce item %s", getText() );
QAction* act = new QAction( getText(), NULL );
act->setAutoRepeat( getAutoRepeat() );
act->setCheckable( getCheckable() );
act->setChecked( getChecked() );
act->setData( getData() );
act->setFont( getFont() );
act->setIcon( getIcon() );
act->setIconVisibleInMenu( getIconVisibleInMenu() );
act->setMenuRole( getMenuRole() );
act->setSeparator( m_Type == AT_SEPARATOR );
act->setShortcut( getShortcut() );
act->setShortcutContext( getShortcutContext() );
act->setStatusTip( getStatusTip() );
act->setToolTip( getTooltip() );
act->setVisible( getVisible() );
act->setWhatsThis( getWhatsThis() );
return act;
};
示例7: populateMenu
void MainWindow::populateMenu()
{
m_acCloseSession = new QAction(tr("Close session"),this);
m_acCloseSession->setShortcut(Qt::ALT + Qt::Key_F3);
connect(m_acCloseSession,SIGNAL(triggered()),SLOT(closeSession()));
m_acClose = new QAction(tr("Close"),this);
m_acClose->setShortcut(Qt::ALT + Qt::Key_F4);
connect(m_acClose, SIGNAL(triggered()), SLOT(close()));
QAction *aboutQt = new QAction(tr("About Qt..."),this);
aboutQt->setMenuRole(QAction::AboutQtRole);
connect(aboutQt,SIGNAL(triggered()),qApp, SLOT(aboutQt()));
registerAction("close_session", m_acCloseSession);
registerAction("close",m_acClose);
registerActions(ReportManager::instance()->actions());
registerActions(PluginManager::instance()->pluginActions());
//m_pluginActionById
generateMenuFromXml(m_core->currentUser()->gui());
}
示例8: QIcon
/**
* @brief Add static entries to DP in menus
**/
QAction *addDPStaticEntry( QMenu *menu,
const QString& text,
const char *icon,
const char *member,
const char *shortcut = NULL,
QAction::MenuRole role = QAction::NoRole
)
{
QAction *action = NULL;
#ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
if( !EMPTY_STR( icon ) )
{
if( !EMPTY_STR( shortcut ) )
action = menu->addAction( QIcon( icon ), text, THEDP,
member, qtr( shortcut ) );
else
action = menu->addAction( QIcon( icon ), text, THEDP, member );
}
else
#endif
{
if( !EMPTY_STR( shortcut ) )
action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
else
action = menu->addAction( text, THEDP, member );
}
#ifdef __APPLE__
action->setMenuRole( role );
#else
Q_UNUSED( role );
#endif
action->setData( VLCMenuBar::ACTION_STATIC );
return action;
}
示例9: ConcreteMenuable
MainWindowMenu::MainWindowMenu(widget::MainWindow *mainWindow)
: ConcreteMenuable(menuName()),
m_mainWindow(mainWindow)
{
Node *packages = new Node(tr("Packages"));
m_file.append(packages);
m_file.append(node(m_hideErrors = action(tr("Hide Errors"), QKeySequence::UnknownKey)));
m_file.append(Node::separator());
m_file.append(m_nextNode = node(activeAction(QIcon(ResourceHelper::ref().lookup("arrow_right")), tr("Next"), QKeySequence::NextChild, this, "next")));
m_file.append(m_prevNode = node(activeAction(QIcon(ResourceHelper::ref().lookup("arrow_left")), tr("Previous"), QKeySequence::PreviousChild, this, "previous")));
m_file.append(m_closeNode = node(activeAction("cross", tr("Close"), QKeySequence::Close, this, "closeCurrentTab")));
m_file.append(Node::separator());
QAction *quit = activeAction("cross", tr("Quit"), QKeySequence::Quit, this, "close");
quit->setMenuRole(QAction::QuitRole);
m_file.append(node(quit));
m_edit.append(Node::separator());
m_edit.append(node(activeAction("cog.png", tr("Settings"), QKeySequence::Preferences, this, "settings")));
m_edit.append(node(activeAction("palette.png", tr("Theme Settings"), QKeySequence::Preferences, this, "theme")));
QAction *about = activeAction("information", tr("About KISS IDE"), QKeySequence::UnknownKey, this, "about");
m_help.append(node(about));
#ifdef ENABLE_LOG_WINDOW
m_help.append(node(m_errorLog = action(tr("Error Log"), QKeySequence::UnknownKey)));
#endif
}
示例10: defined
void
TomahawkWindow::setupUpdateCheck()
{
#ifndef Q_WS_MAC
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
#endif
#if defined( Q_WS_MAC ) && defined( HAVE_SPARKLE )
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
#elif defined( Q_WS_WIN )
QUrl updaterUrl;
if ( qApp->arguments().contains( "--debug" ) )
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin-debug" );
else
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin" );
qtsparkle::Updater* updater = new qtsparkle::Updater( updaterUrl, this );
Q_ASSERT( TomahawkUtils::nam() != 0 );
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
ui->menu_Help->addSeparator();
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
#endif
}
示例11: contextMenuEvent
void ASpellTextEdit::contextMenuEvent (QContextMenuEvent* event)
{
QMenu* menu = createStandardContextMenu();
if (m_spellchecker != NULL)
{
QString selected_text = textCursor().selectedText();
if (selected_text.length() > 0)
{
m_suggest_list.clear();
if (m_spellchecker->spellWord(selected_text, &m_suggest_list) == 1)
{
if (m_suggest_list.count() > 0)
{
menu->addSeparator();
for (int i = 0; i < m_suggest_list.count() && i < 10; i++)
{
QAction* action = menu->addAction(m_suggest_list[i]);
action->setMenuRole(QAction::ApplicationSpecificRole);
}
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_triggered(QAction*)));
menu->addSeparator();
QAction* action = menu->addAction(QString::fromUtf8("Добавить в словарь"));
connect(action, SIGNAL(triggered()), this, SLOT(menu_add_triggered()));
}
}
示例12: psFirstShow
void PsMainWindow::psFirstShow() {
finished = false;
psUpdateMargins();
bool showShadows = true;
show();
_private.enableShadow(winId());
if (cWindowPos().maximized) {
setWindowState(Qt::WindowMaximized);
}
if ((cFromAutoStart() && cStartMinimized()) || cStartInTray()) {
setWindowState(Qt::WindowMinimized);
if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) {
hide();
} else {
show();
}
showShadows = false;
} else {
show();
}
posInited = true;
// init global menu
QMenu *main = psMainMenu.addMenu(qsl("Telegram"));
main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram")), App::wnd()->getTitle(), SLOT(onAbout()))->setMenuRole(QAction::AboutQtRole);
main->addSeparator();
QAction *prefs = main->addAction(lang(lng_mac_menu_preferences), App::wnd(), SLOT(showSettings()), QKeySequence(Qt::ControlModifier | Qt::Key_Comma));
prefs->setMenuRole(QAction::PreferencesRole);
QMenu *file = psMainMenu.addMenu(lang(lng_mac_menu_file));
psLogout = file->addAction(lang(lng_mac_menu_logout), App::wnd(), SLOT(onLogout()));
QMenu *edit = psMainMenu.addMenu(lang(lng_mac_menu_edit));
psUndo = edit->addAction(lang(lng_mac_menu_undo), this, SLOT(psMacUndo()), QKeySequence::Undo);
psRedo = edit->addAction(lang(lng_mac_menu_redo), this, SLOT(psMacRedo()), QKeySequence::Redo);
edit->addSeparator();
psCut = edit->addAction(lang(lng_mac_menu_cut), this, SLOT(psMacCut()), QKeySequence::Cut);
psCopy = edit->addAction(lang(lng_mac_menu_copy), this, SLOT(psMacCopy()), QKeySequence::Copy);
psPaste = edit->addAction(lang(lng_mac_menu_paste), this, SLOT(psMacPaste()), QKeySequence::Paste);
psDelete = edit->addAction(lang(lng_mac_menu_delete), this, SLOT(psMacDelete()), QKeySequence(Qt::ControlModifier | Qt::Key_Backspace));
edit->addSeparator();
psSelectAll = edit->addAction(lang(lng_mac_menu_select_all), this, SLOT(psMacSelectAll()), QKeySequence::SelectAll);
QMenu *window = psMainMenu.addMenu(lang(lng_mac_menu_window));
psContacts = window->addAction(lang(lng_mac_menu_contacts), App::wnd()->getTitle(), SLOT(onContacts()));
psAddContact = window->addAction(lang(lng_mac_menu_add_contact), App::wnd(), SLOT(onShowAddContact()));
window->addSeparator();
psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup()));
psNewChannel = window->addAction(lang(lng_mac_menu_new_channel), App::wnd(), SLOT(onShowNewChannel()));
window->addSeparator();
psShowTelegram = window->addAction(lang(lng_mac_menu_show), App::wnd(), SLOT(showFromTray()));
psMacUpdateMenu();
}
示例13: setupMenu
void MainWindow::setupMenu() {
menuBar()->clear();
// File
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *config = fileMenu->addAction(tr("&Configure"), this, SLOT(slotConfigure()));
config->setMenuRole(QAction::PreferencesRole);
fileMenu->addSeparator();
QAction *quit = fileMenu->addAction(tr("&Quit"), qApp, SLOT(quit()));
quit->setMenuRole( QAction::QuitRole );
// Help
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addSeparator();
QAction *aboutQt = helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
aboutQt->setMenuRole( QAction::AboutQtRole );
QAction *aboutTelldusCenter = helpMenu->addAction(tr("About &TelldusCenter"), this, SLOT(slotAboutApplication()));
aboutTelldusCenter->setMenuRole( QAction::AboutRole );
}
示例14: QAction
// ---------------------------------------------------------------------
QAction *Menus::makeact(string id, string p)
{
QStringList s=qsplit(p);
QString text=s.value(0);
QString shortcut=s.value(1);
QAction *r = new QAction(text,widget);
QString name=s2q(id);
r->setObjectName(name);
r->setMenuRole(QAction::NoRole);
if (shortcut.size())
r->setShortcut(shortcut);
items[name]=r;
return r;
}
示例15: AppSettingsGUI
AppSettingsGUIImpl::AppSettingsGUIImpl(QObject* p) : AppSettingsGUI(p)
{
registerBuiltinPages();
QMenu* m = AppContext::getMainWindow()->getTopLevelMenu(MWMENU_SETTINGS);
QAction* settingsDialogAction = new QAction(QIcon(":ugene/images/preferences.png"), tr("Preferences..."), this);
connect(settingsDialogAction, SIGNAL(triggered()), SLOT(sl_showSettingsDialog()));
settingsDialogAction->setObjectName("action__settings");
#ifdef Q_OS_MAC
settingsDialogAction->setMenuRole(QAction::ApplicationSpecificRole);
settingsDialogAction->setShortcut(QKeySequence("Ctrl+,"));
settingsDialogAction->setShortcutContext(Qt::ApplicationShortcut);
#endif
m->addAction(settingsDialogAction);
AppContext::getMainWindow()->registerAction(settingsDialogAction);
}