当前位置: 首页>>代码示例>>C++>>正文


C++ QMenuBar::addSeparator方法代码示例

本文整理汇总了C++中QMenuBar::addSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::addSeparator方法的具体用法?C++ QMenuBar::addSeparator怎么用?C++ QMenuBar::addSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMenuBar的用法示例。


在下文中一共展示了QMenuBar::addSeparator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

void MenuManager::setup(MenuItem* menuItems) const
{
    if (!menuItems)
        return; // empty menu bar

    QMenuBar* menuBar = getMainWindow()->menuBar();
    //menuBar->setUpdatesEnabled(false);

    QList<MenuItem*> items = menuItems->getItems();
    QList<QAction*> actions = menuBar->actions();
    for (QList<MenuItem*>::ConstIterator it = items.begin(); it != items.end(); ++it)
    {
        // search for the menu action
        QAction* action = findAction(actions, QString::fromAscii((*it)->command().c_str()));
        if (!action) {
            // There must be not more than one separator in the menu bar, so
            // we can safely remove it if available and append it at the end
            if ((*it)->command() == "Separator") {
                action = menuBar->addSeparator();
                action->setObjectName(QLatin1String("Separator"));
            }
            else {
                // create a new menu
                std::string menuName = (*it)->command();
                QMenu* menu = menuBar->addMenu(
                    QApplication::translate("Workbench", menuName.c_str(),
                                            0, QApplication::UnicodeUTF8));
                action = menu->menuAction();
                menu->setObjectName(QString::fromAscii(menuName.c_str()));
                action->setObjectName(QString::fromAscii(menuName.c_str()));
            }

            // set the menu user data
            action->setData(QString::fromAscii((*it)->command().c_str()));
        }
        else {
            // put the menu at the end
            menuBar->removeAction(action);
            menuBar->addAction(action);
            action->setVisible(true);
            int index = actions.indexOf(action);
            actions.removeAt(index);
        }

        // flll up the menu
        if (!action->isSeparator())
            setup(*it, action->menu());
    }

    // hide all menus which we don't need for the moment
    for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) {
        (*it)->setVisible(false);
    }

    // enable update again
    //menuBar->setUpdatesEnabled(true);
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:57,代码来源:MenuManager.cpp

示例2: setMenuBar

void Ui::MainWindow::createMenus()
{
    QMenuBar *mb = actionManager->menuBar(Core::ID::MENU_BAR);
#ifndef Q_WS_MAC // System menu bar on Mac
    setMenuBar(mb);
#endif
    QMenu *fileMenu = actionManager->menu(Core::ID::MENU_FILE, tr("&File", "[File] on menu bar."));
    fileMenu->addAction(newAction);
    fileMenu->addAction(openAction);
    fileMenu->addSeparator();
    fileMenu->addAction(saveAction);
    fileMenu->addAction(saveAsAction);
    fileMenu->addAction(saveAllAction);
    fileMenu->addSeparator();
    fileMenu->addAction(printAction);
    fileMenu->addSeparator();
    fileMenu->addAction(exitAction);
    mb->addMenu(fileMenu);

    QMenu *editMenu = actionManager->menu(Core::ID::MENU_EDIT, tr("&Edit", "[Edit] on menu bar."));
    editMenu->addAction(undoAction);
    editMenu->addAction(redoAction);
    editMenu->addSeparator();
    editMenu->addAction(cutAction);
    editMenu->addAction(copyAction);
    editMenu->addAction(pasteAction);
    mb->addMenu(editMenu);

    QMenu *toolMenu = actionManager->menu(Core::ID::MENU_TOOL, tr("&Tools", "[Tools] on menu bar."));
    QMenu *langMenu = actionManager->menu(Core::ID::MENU_LANG, tr("Languages", "[Language] under menu [Tool]"));
    toolMenu->addMenu(langMenu);
    toolMenu->addAction(preferencesAction);
    mb->addMenu(toolMenu);

    QtWindowListMenu *subwindowMenu = new QtWindowListMenu;
    subwindowMenu->attachToMdiArea(mdiArea);
    subwindowMenu->setCascadeIcon(QIcon(":/acts/cascade"));
    subwindowMenu->setTileIcon(QIcon(":/acts/tile"));
    mb->addMenu(subwindowMenu);

    mb->addSeparator();

    QMenu *helpMenu = actionManager->menu(Core::ID::MENU_HELP, tr("&Help", "[Help] on menu bar."));
    helpMenu->addAction(helpAction);
    helpMenu->addAction(aboutAction);
    mb->addMenu(helpMenu);
}
开发者ID:jaisurya,项目名称:picworks,代码行数:47,代码来源:mainwindow.cpp

示例3: setupActions

void QucsHelp::setupActions()
{
  QToolBar *toolbar = addToolBar(tr("Main toolbar"));
  QMenuBar *bar = menuBar();
  statusBar();

  QMenu *fileMenu = bar->addMenu(tr("&File"));
  QMenu *viewMenu = bar->addMenu(tr("&View"));
  bar->addSeparator();
  QMenu *helpMenu = bar->addMenu(tr("&Help"));
  
  QAction *quitAction = fileMenu->addAction(QIcon(QucsSettings.BitmapDir + "quit.png"),tr("&Quit"),qApp,SLOT(quit()),Qt::CTRL+Qt::Key_Q);

  QAction *backAction = viewMenu->addAction(QIcon(QucsSettings.BitmapDir + "back.png"), tr("&Back"),textBrowser,SLOT(backward()),
					    Qt::ALT+Qt::Key_Left);
  QAction *forwardAction = viewMenu->addAction(QIcon(QucsSettings.BitmapDir + "forward.png"),tr("&Forward"),textBrowser,
					       SLOT(forward()),Qt::ALT+Qt::Key_Right);
  QAction *homeAction = viewMenu->addAction(QIcon(QucsSettings.BitmapDir + "home.png"),tr("&Home"),textBrowser,
					    SLOT(home()),Qt::CTRL+Qt::Key_H);

  previousAction = viewMenu->addAction(QIcon(QucsSettings.BitmapDir + "previous.png"),tr("&Previous"),this,SLOT(previousLink()));
  nextAction = viewMenu->addAction(QIcon(QucsSettings.BitmapDir + "next.png"),tr("&Next"),this,SLOT(nextLink()));
  viewMenu->addSeparator();

  QAction *viewBrowseDock = dock->toggleViewAction();
  viewMenu->addAction(viewBrowseDock);
  viewBrowseDock->setStatusTip(tr("Enables/disables the table of contents"));
  viewBrowseDock->setWhatsThis(tr("Table of Contents\n\nEnables/disables the table of contents"));

  helpMenu->addAction(tr("&About Qt"),qApp,SLOT(aboutQt()));

  connect(textBrowser,SIGNAL(backwardAvailable(bool)),backAction,SLOT(setEnabled(bool)));
  connect(textBrowser,SIGNAL(forwardAvailable(bool)),forwardAction,SLOT(setEnabled(bool)));
  connect(textBrowser,SIGNAL(sourceChanged(const QUrl &)),this,SLOT(slotSourceChanged(const QUrl &)));
  
  toolbar->addAction(backAction);
  toolbar->addAction(forwardAction);
  toolbar->addSeparator();
  toolbar->addAction(homeAction);
  toolbar->addAction(previousAction);
  toolbar->addAction(nextAction);
  toolbar->addSeparator();
  toolbar->addAction(quitAction);
}
开发者ID:damiansimanuk,项目名称:qucs-qt4,代码行数:44,代码来源:qucshelp.cpp

示例4: QWidget

MyWidget::MyWidget( QWidget *parent, const char *name )
: QWidget( parent/*, name */)
{
	setWindowTitle("Color Codes");

  // icons are handled differently on OSX
#ifndef __APPLE__
  setWindowIcon(QPixmap(":/bitmaps/big.qucs.xpm"));
#endif

	 // --------  create menubar  -------------------
  QAction *fileExit = new QAction(tr("E&xit"), this);
  fileExit->setShortcut(Qt::CTRL+Qt::Key_Q);
  connect(fileExit, SIGNAL(activated()), qApp, SLOT(quit()));

  QMenu *fileMenu = new QMenu(tr("&File"));
  fileMenu->addAction(fileExit);

  QAction *help = new QAction(tr("Help..."), this);
  help->setShortcut(Qt::Key_F1);
  connect(help, SIGNAL(activated()), this, SLOT(slotHelpIntro()));

  QAction *about = new QAction(tr("&About ResistorCodes..."), this);
  connect(about, SIGNAL(activated()), this, SLOT(slotHelpAbout()));

  QAction *aboutQt = new QAction(tr("&About Qt..."), this);
  connect(aboutQt, SIGNAL(activated()), this, SLOT(slotHelpAboutQt()));

  QMenu *helpMenu = new QMenu(tr("&Help"));
  helpMenu->addAction(help);
  helpMenu->addAction(about);
  helpMenu->addSeparator();
  helpMenu->addAction(aboutQt);

  QMenuBar *menuBar = new QMenuBar(this);
	menuBar->addMenu(fileMenu);
	menuBar->addSeparator();
	menuBar->addMenu(helpMenu);

	res= new QResistor();
	//--------------------resistance displayin ui ---------------------------------//
	resBox = new MyResistanceBox (this);

	connect(res, SIGNAL(valueModified(QResistor*)),resBox,SLOT(update(QResistor*)));
	//-------------------color displaying ui---------------------------------------------//
	colorBox = new MyColorBox(this);

	connect(res, SIGNAL(valueModified(QResistor*)),colorBox,SLOT(update(QResistor*)));

	//-------------------paste the configuration to clipboard--------------------------------------------//
	connect(res, SIGNAL(valueModified(QResistor*)),this,SLOT(slotConfiguration()));
	//-------------------switching buttons ui--------------------------------------//
  QPushButton *calcColor = new QPushButton(QPixmap(":/bitmaps/next.png")," To Colors", this );
    calcColor->setObjectName("calcColor");
    
	connect(calcColor, SIGNAL(clicked()),this,SLOT(setResistanceValue()));

	QPushButton *calcResistance = new QPushButton(QPixmap(":/bitmaps/previous.png")," To Resistance", this);
    calcColor->setObjectName( "calcResistance" );
    
	connect(calcResistance, SIGNAL(clicked()),this,SLOT(setColorValue()));

	QPushButton *quit = new QPushButton( "Quit", this );
    calcColor->setObjectName("quit");
    
	connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );

  QHBoxLayout *buttonBox = new QHBoxLayout;
  buttonBox->addWidget(calcColor);
  buttonBox->addWidget(calcResistance);
  buttonBox->addWidget(quit);

	//--------------------packing all of them together---------------------------------------//
  QGridLayout *grid = new QGridLayout(this);
  grid->setMargin(10);

#ifndef __APPLE__
    QWidget *Space = new QWidget(this);   // reserve space for menubar
    Space->setFixedSize(1, menuBar->height());
    grid->addWidget(Space, 0,0);
#endif

	grid->addWidget( resBox, 1, 0 );
	grid->addLayout( buttonBox, 2, 0 );
	grid->addWidget( colorBox, 3, 0 );

}
开发者ID:mdavidsaver,项目名称:qucs,代码行数:87,代码来源:main.cpp

示例5: run

void MainWindow::run()
{
	// Allow the user to enable or disable debugging
	// We handle this before the other parameters, as it may affect some
	// early debug messages
        QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, parser->isSet("debug"));

	readSettings();

	setAttribute(Qt::WA_DeleteOnClose, true);

	// menu structure

	QMenuBar *menuBar = QMainWindow::menuBar();
	collection = new KActionCollection(this);

	QMenu *menu = new QMenu(i18n("&File"), this);
	menuBar->addMenu(menu);

	QAction *action = KStandardAction::open(this, SLOT(open()), collection);
	menu->addAction(collection->addAction(QLatin1String("file_open"), action));

	action = new QAction(QIcon::fromTheme(QLatin1String("text-html"), QIcon(":text-html")),
		i18nc("@action:inmenu", "Open URL..."), collection);
	action->setShortcut(Qt::CTRL | Qt::Key_U);
	connect(action, SIGNAL(triggered(bool)), this, SLOT(openUrl()));
	menu->addAction(collection->addAction(QLatin1String("file_open_url"), action));

	actionOpenRecent = KStandardAction::openRecent(this, SLOT(openUrl(QUrl)), collection);
	actionOpenRecent->loadEntries(KSharedConfig::openConfig()->group("Recent Files"));
	menu->addAction(collection->addAction(QLatin1String("file_open_recent"), actionOpenRecent));

	menu->addSeparator();

	action = new QAction(QIcon::fromTheme(QLatin1String("media-optical-audio"), QIcon(":media-optical-audio")), i18n("Play Audio CD"), collection);
	connect(action, SIGNAL(triggered(bool)), this, SLOT(openAudioCd()));
	menu->addAction(collection->addAction(QLatin1String("file_play_audiocd"), action));

	action = new QAction(QIcon::fromTheme(QLatin1String("media-optical"), QIcon(":media-optical")), i18n("Play Video CD"), collection);
	connect(action, SIGNAL(triggered(bool)), this, SLOT(openVideoCd()));
	menu->addAction(collection->addAction(QLatin1String("file_play_videocd"), action));

	action = new QAction(QIcon::fromTheme(QLatin1String("media-optical"), QIcon(":media-optical")), i18n("Play DVD"), collection);
	connect(action, SIGNAL(triggered(bool)), this, SLOT(openDvd()));
	menu->addAction(collection->addAction(QLatin1String("file_play_dvd"), action));

	action = new QAction(QIcon::fromTheme(QLatin1String("media-optical"), QIcon(":media-optical")), i18nc("@action:inmenu", "Play DVD Folder"),
		collection);
	connect(action, SIGNAL(triggered()), this, SLOT(playDvdFolder()));
	menu->addAction(collection->addAction(QLatin1String("file_play_dvd_folder"), action));

	menu->addSeparator();

	action = KStandardAction::quit(this, SLOT(close()), collection);
	menu->addAction(collection->addAction(QLatin1String("file_quit"), action));

	QMenu *playerMenu = new QMenu(i18n("&Playback"), this);
	menuBar->addMenu(playerMenu);

	QMenu *playlistMenu = new QMenu(i18nc("menu bar", "Play&list"), this);
	menuBar->addMenu(playlistMenu);

#if HAVE_DVB == 1
	QMenu *dvbMenu = new QMenu(i18n("&Television"), this);
	menuBar->addMenu(dvbMenu);
#endif /* HAVE_DVB == 1 */

	menu = new QMenu(i18n("&Settings"), this);
	menuBar->addMenu(menu);

	action = KStandardAction::keyBindings(this, SLOT(configureKeys()), collection);
	menu->addAction(collection->addAction(QLatin1String("settings_keys"), action));

	action = KStandardAction::preferences(this, SLOT(configureKaffeine()), collection);
	menu->addAction(collection->addAction(QLatin1String("settings_kaffeine"), action));

	menuBar->addSeparator();
	KHelpMenu *helpMenu = new KHelpMenu(this, *aboutData);
	menuBar->addMenu(helpMenu->menu());

	// navigation bar - keep in sync with TabIndex enum!

	navigationBar = new QToolBar(QLatin1String("navigation_bar"));
	this->addToolBar(Qt::LeftToolBarArea, navigationBar);
	connect(navigationBar, SIGNAL(orientationChanged(Qt::Orientation)),
		this, SLOT(navigationBarOrientationChanged(Qt::Orientation)));

	tabBar = new QTabBar(navigationBar);
	tabBar->addTab(QIcon::fromTheme(QLatin1String("start-here-kde"), QIcon(":start-here-kde")), i18n("Start"));
	tabBar->addTab(QIcon::fromTheme(QLatin1String("kaffeine"), QIcon(":kaffeine")), i18n("Playback"));
	tabBar->addTab(QIcon::fromTheme(QLatin1String("view-media-playlist"), QIcon(":view-media-playlist")), i18n("Playlist"));
#if HAVE_DVB == 1
	tabBar->addTab(QIcon::fromTheme(QLatin1String("video-television"), QIcon(":video-television")), i18n("Television"));
#endif /* HAVE_DVB == 1 */
	tabBar->setShape(QTabBar::RoundedWest);
	tabBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
	connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(activateTab(int)));
	navigationBar->addWidget(tabBar);

	// control bar
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:kaffeine,代码行数:101,代码来源:mainwindow.cpp

示例6: createMenus

void MainWindow::createMenus()
{
    QMenuBar *bar = this->menuBar();

    QMenu *fileMenu = new QMenu(tr("&File"), bar);
    fileMenu->addAction(newPostAct);
    fileMenu->addAction(openPostAct);
    fileMenu->addAction(closePostAct);
    fileMenu->addSeparator();
    fileMenu->addAction(savePostAct);
    fileMenu->addAction(saveAsPostAct);
    fileMenu->addSeparator();
    fileMenu->addAction(exitAct);
    bar->addMenu(fileMenu);

    QMenu *editMenu = new QMenu(tr("&Edit"), bar);
    editMenu->addAction(undoAct);
    editMenu->addAction(redoAct);
    editMenu->addSeparator();
    editMenu->addAction(cutAct);
    editMenu->addAction(copyAct);
    editMenu->addAction(pasteAct);
    bar->addMenu(editMenu);

    QMenu *formatMenu = new QMenu(tr("F&ormat"), bar);
    formatMenu->addAction(textFontAct);
    formatMenu->addAction(textColorAct);
    formatMenu->addAction(textBackgroundColorAct);
    formatMenu->addSeparator();
    QMenu *alignMenu = new QMenu(tr("Alignment"), formatMenu);
    if(QApplication::isLeftToRight()) {
        alignMenu->addAction(alignLeftAct);
        alignMenu->addAction(alignCenterAct);
        alignMenu->addAction(alignRightAct);
    } else {
        alignMenu->addAction(alignRightAct);
        alignMenu->addAction(alignCenterAct);
        alignMenu->addAction(alignLeftAct);
    }
    alignMenu->addAction(alignJustifyAct);
    formatMenu->addMenu(alignMenu);
    bar->addMenu(formatMenu);

    QMenu *insertMenu = new QMenu(tr("&Insert"), bar);
    QMenu *listMenu = new QMenu(tr("List"), insertMenu);
    listMenu->addAction(bulletListAct);
    listMenu->addAction(numberedListAct);
    listMenu->addSeparator();
    listMenu->addAction(indentMoreAct);
    listMenu->addAction(indentLessAct);
    insertMenu->addMenu(listMenu);
    QMenu *tableMenu = createTableMenu(insertMenu);
    insertMenu->addMenu(tableMenu);
    bar->addMenu(insertMenu);

    QMenu *toolMenu = new QMenu(tr("&Tools"), bar);
    toolMenu->addAction(pluginAct);
    bar->addMenu(toolMenu);

    bar->addSeparator();

    QMenu *helpMenu = new QMenu(tr("Help"), bar);
    helpMenu->addAction(helpAct);
    helpMenu->addAction(aboutAct);
    bar->addMenu(helpMenu);
}
开发者ID:orangestar,项目名称:orbitswriter,代码行数:66,代码来源:mainwindow.cpp


注:本文中的QMenuBar::addSeparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。