本文整理汇总了C++中QMenuBar::insertMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::insertMenu方法的具体用法?C++ QMenuBar::insertMenu怎么用?C++ QMenuBar::insertMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::insertMenu方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extensionsInitialized
void QtTestPlugin::extensionsInitialized()
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
m_messageOutputWindow = new TestOutputWindow();
pm->addObject(m_messageOutputWindow);
m_testResultsWindow = TestResultsWindow::instance();
connect(m_testResultsWindow, SIGNAL(stopTest()), this, SLOT(stopTesting()));
connect(m_testResultsWindow, SIGNAL(retryFailedTests(QStringList)),
this, SLOT(retryTests(QStringList)));
connect(TestExecuter::instance(), SIGNAL(testStarted()),
m_testResultsWindow, SLOT(onTestStarted()));
connect(TestExecuter::instance(), SIGNAL(testStop()),
m_testResultsWindow, SLOT(onTestStopped()));
connect(TestExecuter::instance(), SIGNAL(testFinished()),
m_testResultsWindow, SLOT(onTestFinished()));
pm->addObject(m_testResultsWindow);
connect(testResultsPane(), SIGNAL(defectSelected(TestCaseRec)),
this, SLOT(onDefectSelected(TestCaseRec)));
// Add context menu to CPP editor
Core::ActionContainer *mcontext = am->actionContainer(CppEditor::Constants::M_CONTEXT);
m_contextMenu->init(mcontext->menu(), 2, this);
// Add context menu to JS editor
mcontext = am->actionContainer(QmlJSEditor::Constants::M_CONTEXT);
m_contextMenu->init(mcontext->menu(), 2, this);
// Add a Test menu to the menu bar
Core::ActionContainer* ac = am->createMenu("QtTestPlugin.TestMenu");
ac->menu()->setTitle(tr("&Test"));
m_contextMenu->init(ac->menu(), 0, 0);
// Insert the "Test" menu between "Window" and "Help".
QMenu *windowMenu = am->actionContainer(Core::Constants::M_TOOLS)->menu();
QMenuBar *menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar();
menuBar->insertMenu(windowMenu->menuAction(), ac->menu());
ProjectExplorer::ProjectExplorerPlugin *explorer =
ProjectExplorer::ProjectExplorerPlugin::instance();
connect(explorer->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(onStartupProjectChanged(ProjectExplorer::Project *)));
connect(core->progressManager(), SIGNAL(allTasksFinished(QString)),
this, SLOT(onAllTasksFinished(QString)));
connect(explorer->session(), SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
this, SLOT(onProjectRemoved(ProjectExplorer::Project *)));
m_contextMenu->init(0, 3, this);
}
示例2: createMenus
void DoNothingPlugin::createMenus()
{
// Fetch the action manager
Core::ActionManager* am = Core::ICore::instance()->actionManager();
// Create a DoNothing menu
Core::ActionContainer* ac = am->createMenu("DoNothingPlugin.DoNothingMenu");
ac->menu()->setTitle(tr("DoNothing"));
// Create a command for "About DoNothing".
Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing", QList<int>() << 0);
cmd->action()->setText("About DoNothing");
// Add DoNothing menu to the beginning of the menu bar
am->actionContainer(Core::Constants::MENU_BAR)->addMenu(ac);
// Add the "About DoNothing" action to the DoNothing menu
ac->addAction(cmd);
// Connect the action
connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
// Create a DoNothing2 menu
Core::ActionContainer* ac2 = am->createMenu("DoNothingPlugin.DoNothing2Menu");
ac2->menu()->setTitle(tr("DoNothing2"));
// Create a command for "About DoNothing 2".
Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2", QList<int>() << 0);
cmd2->action()->setText("About DoNothing 2");
// Insert the "DoNothing" menu between "Window" and "Help".
QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu();
QMenuBar* menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar();
menuBar->insertMenu(helpMenu->menuAction(), ac2->menu());
// Add the "About DoNothing 2" action to the DoNothing2 menu
ac2->addAction(cmd2);
// Connect the action
connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
}
示例3: init1
// ========================================================
int init1 ( )
{
BL_FUNC_DEBUG
PluginBl_Report *mcont = new PluginBl_Report;
QMenu *pPluginMenu = NULL;
/// Miramos si existe un menu Informes
pPluginMenu = g_pluginbl_report->menuBar()->findChild<QMenu *> ( "menuInformes" );
QMenu *pPluginVer = g_pluginbl_report->menuBar()->findChild<QMenu *> ( "menuVentana" );
/// Buscamos ficheros adecuados
QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) );
dir.setFilter ( QDir::Files | QDir::NoSymLinks );
dir.setSorting ( QDir::Size | QDir::Reversed );
/// Hacemos un filtrado de busqueda
QStringList filters;
filters << "inf_*.txt";
dir.setNameFilters ( filters );
QFileInfoList list = dir.entryInfoList();
for ( int i = 0; i < list.size(); ++i ) {
QFileInfo fileInfo = list.at ( i );
QFile file;
file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() );
file.open ( QIODevice::ReadOnly );
QTextStream stream ( &file );
QString buff = stream.readAll();
file.close();
/// Buscamos el titulo
QString titulo = fileInfo.fileName();
QRegExp rx3 ( " title\\s*=\\s*\"(.*)\"" );
rx3.setMinimal ( true );
if ( rx3.indexIn ( buff, 0 ) != -1 ) {
titulo = rx3.cap ( 1 );
} // end while
QString pathtitulo = fileInfo.fileName();
QRegExp rx1 ( "pathtitle\\s*=\\s*\"(.*)\"" );
rx1.setMinimal ( true );
if ( rx1.indexIn ( buff, 0 ) != -1 ) {
pathtitulo = rx1.cap ( 1 );
} else {
pathtitulo = titulo;
} // end while
/// Buscamos el icono
QString icon = ":/Images/template2rml.png";
QRegExp rx6 ( " icon\\s*=\\s*\"(.*)\"" );
rx6.setMinimal ( true );
if ( rx6.indexIn ( buff, 0 ) != -1 ) {
icon = rx6.cap ( 1 );
} // end while
QMenuBar *menubar =g_pluginbl_report->menuBar();
QMenu *menu = NULL;
QStringList path = pathtitulo.split("\\");
if (path.size() > 1) {
QList<QMenu *> allPButtons = menubar->findChildren<QMenu *>();
bool encontrado = false;
for (int j = 0; j < allPButtons.size(); ++j) {
if (allPButtons.at(j)->title() == path[0]) {
encontrado = true;
menu = allPButtons.at(j);
} // end if
} // end for
if (!encontrado) {
QMenu *pPluginMenu1 = new QMenu (path[0] , menubar );
menubar->insertMenu ( pPluginVer->menuAction(), pPluginMenu1 );
menu = pPluginMenu1;
} // end if
} else {
if (!pPluginMenu) {
pPluginMenu = new QMenu ( _ ( "Informes" ), g_pluginbl_report->menuBar() );
pPluginMenu->setObjectName ( QString::fromUtf8 ( "menuInformes" ) );
g_pluginbl_report->menuBar()->insertMenu ( pPluginVer->menuAction(), pPluginMenu );
} // end if
menu = pPluginMenu;
} // end if
for (int i = 1; i < path.size()-1; ++i) {
QList<QMenu *> allPButtons = menu->findChildren<QMenu *>();
bool encontrado = false;
for (int j = 0; j < allPButtons.size(); ++j) {
if (allPButtons.at(j)->title() == path[i]) {
encontrado = true;
//.........这里部分代码省略.........