本文整理汇总了C++中QMenuBar::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::setObjectName方法的具体用法?C++ QMenuBar::setObjectName怎么用?C++ QMenuBar::setObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::setObjectName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QMenuBar *menuBar;
QToolBar *mainToolBar;
QWidget *centralWidget;
QStatusBar *statusBar;
if (this->objectName().isEmpty())
this->setObjectName(QString::fromUtf8("MainWindow"));
this->resize(400, 300);
menuBar = new QMenuBar(this);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
this->setMenuBar(menuBar);
mainToolBar = new QToolBar(this);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
this->addToolBar(mainToolBar);
centralWidget = new QWidget(this);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
this->setCentralWidget(centralWidget);
statusBar = new QStatusBar(this);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
this->setStatusBar(statusBar);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
#else
this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
#endif
QMetaObject::connectSlotsByName(this);
}
示例2: menuBar
void MainWindow::init()
{
QMenuBar *myMenuBar = menuBar();
QMenu *fileMenu = myMenuBar->addMenu("File");
QMenu *EditionMenu = myMenuBar->addMenu("Edition");
QMenu *helpMenu = myMenuBar->addMenu("Help");
myMenuBar->setObjectName("myMenuBar");
fileMenu->setObjectName("myFileMenu");
EditionMenu->setObjectName("myEditionMenu");
helpMenu->setObjectName("myHelpMenu");
_dockWidget = new QDockWidget;
_dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures | QDockWidget::DockWidgetMovable);
_dockWidget->setVisible(false);
_stackedWidget = new QStackedWidget;
_accountInterface = AccountSingleton::getInstance();
_centralWidget = CentralWidgetSingleton::getInstance();
_dockWidgetContent = DockWidgetContentSingleton::getInstance();
_stackedWidget->addWidget(_accountInterface);
_stackedWidget->addWidget(_centralWidget);
setCentralWidget(_stackedWidget);
_dockWidget->setWidget(_dockWidgetContent);
_dockWidget->setMinimumSize(400, 600);
addDockWidget(Qt::LeftDockWidgetArea, _dockWidget, Qt::Vertical);
setWindowTitle("Babel Client");
setMinimumSize(800, 700);
connect(ListenServerSingleton::getInstance(), SIGNAL(connected()), this, SLOT(switchOnConnectedState()));
connect(ListenServerSingleton::getInstance(), SIGNAL(warningPopUp(QString const&,QString const&)),
this, SLOT(showWarningPopUp(QString const&,QString const&)));
connect(ListenServerSingleton::getInstance(), SIGNAL(successPopUp(QString const&,QString const&)),
this, SLOT(showSuccessPopUp(QString const&,QString const&)));
connect(ListenServerSingleton::getInstance(), SIGNAL(contactStatusChanged(QString,int)), _dockWidgetContent, SLOT(updateStatusForContact(QString,int)));
connect(ListenServerSingleton::getInstance(), SIGNAL(callOccured(QString const &, unsigned int)), _centralWidget, SLOT(showCallPopUp(QString const &, unsigned int)));
connect(ListenServerSingleton::getInstance(), SIGNAL(callFail()), _centralWidget, SLOT(showFailCall()));
connect(ListenServerSingleton::getInstance(), SIGNAL(newContactToUpdateList(QString const &)), _dockWidgetContent, SLOT(addContactToUpdateList(QString const &)));
connect(ListenServerSingleton::getInstance(), SIGNAL(textMessageChanged(QString const &)), _centralWidget, SLOT(updateTalkWindowText(QString const&)));
connect(ListenServerSingleton::getInstance(), SIGNAL(hungUp(QString const &)), _centralWidget, SLOT(applyHangUp(QString const&)));
connect(_dockWidgetContent, SIGNAL(called()), _centralWidget, SLOT(call()));
}
示例3: QMenuBar
QMenuBar *TeamBuilder::createMenuBar(MainEngine *w)
{
QMenuBar *menuBar = new QMenuBar();
menuBar->setObjectName("TeamBuilder");
QMenu *fileMenu = menuBar->addMenu(tr("&File"));
fileMenu->addAction(tr("&New"),this,SLOT(newTeam()),tr("Ctrl+N", "New"));
fileMenu->addAction(tr("&Save all"),this,SLOT(saveAll()),tr("Ctrl+S", "Save all"));
fileMenu->addAction(tr("&Load all"),this,SLOT(openLoadWindow()),tr("Ctrl+L", "Load all"));
fileMenu->addSeparator();
fileMenu->addAction(tr("&Quit"),qApp,SLOT(quit()),tr("Ctrl+Q", "Quit"));
QMenu *teamMenu = menuBar->addMenu(tr("&Team"));
if (currentWidget() && currentWidget() == this->teamMenu) {
teamMenu->addAction(tr("Choose pokemon"), this->teamMenu, SLOT(choosePokemon()), tr("Alt+E", "Choose Pokemon"));
}
teamMenu->addAction(tr("Trainer Menu"), this, SLOT(switchToTrainer()), tr("Ctrl+B", "Trainer Menu"));
teamMenu->addSeparator();
teamMenu->addAction(tr("&Add team"), this, SLOT(addTeam()), tr("Ctrl+A", "Add team"));
teamMenu->addAction(tr("&Load team"), this, SLOT(openTeam()), tr("Ctrl+Shift+L", "Load team"));
teamMenu->addAction(tr("&Save team"), this, SLOT(saveTeam()), tr("Ctrl+Shift+S", "Save team"));
teamMenu->addAction(tr("&Import team"), this, SLOT(importTeam()), tr("Ctrl+I", "Import team"));
teamMenu->addAction(tr("&Export team"), this, SLOT(exportTeam()), tr("Ctrl+E", "Export team"));
teamMenu->addSeparator();
teamMenu->addAction(tr("Import from Android"), this, SLOT(importAndroid()), tr("Ctrl+Shift+I", "Import from Android"));
teamMenu->addAction(tr("Export to Android"), this, SLOT(exportAndroid()), tr("Ctrl+Shift+E", "Export to Android"));
currentWidget()->addMenus(menuBar);
/* Loading mod menu */
QMenu *menuMods = menuBar->addMenu(tr("&Mods"));
QActionGroup *group = new QActionGroup(menuMods);
QString currentMod = PokemonInfoConfig::currentMod();
// No mod option.
QAction *noMod = menuMods->addAction(tr("&No mod"), this, SLOT(setNoMod()));
noMod->setCheckable(true);
noMod->setChecked(currentMod.length()==0);
group->addAction(noMod);
menuMods->addSeparator();
QStringList mods = PokemonInfoConfig::availableMods();
foreach(QString smod, mods) {
QAction *mod = menuMods->addAction(smod, this, SLOT(changeMod()));
mod->setProperty("name", smod);
mod->setCheckable(true);
mod->setChecked(currentMod == smod);
group->addAction(mod);
}
示例4: parent
/*!
Creates a new menu bar with the given \a id.
Returns a new ActionContainer that you can use to get the QMenuBar instance
or to add menus to the menu bar. The ActionManager owns
the returned ActionContainer.
*/
ActionContainer *ActionManager::createMenuBar(Id id)
{
const ActionManagerPrivate::IdContainerMap::const_iterator it = d->m_idContainerMap.constFind(id);
if (it != d->m_idContainerMap.constEnd())
return it.value();
QMenuBar *mb = new QMenuBar; // No parent (System menu bar on Mac OS X)
mb->setObjectName(id.toString());
MenuBarActionContainer *mbc = new MenuBarActionContainer(id);
mbc->setMenuBar(mb);
d->m_idContainerMap.insert(id, mbc);
connect(mbc, SIGNAL(destroyed()), d, SLOT(containerDestroyed()));
return mbc;
}
示例5: parent
ActionContainer *ActionManagerPrivate::createMenuBar(const QString &id)
{
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
if (it != m_idContainerMap.constEnd()) {
return it.value();
}
QMenuBar *mb = new QMenuBar; // No parent (System menu bar on Mac OS X)
mb->setObjectName(id);
MenuBarActionContainer *mbc = new MenuBarActionContainer(uid);
mbc->setMenuBar(mb);
m_idContainerMap.insert(uid, mbc);
return mbc;
}
示例6: setupUi
void setupUi(QMainWindow *Detection)
{
if (Detection->objectName().isEmpty())
Detection->setObjectName(QString::fromUtf8("Detection"));
Detection->resize(729, 480);
actionE_xit = new QAction(Detection);
actionE_xit->setObjectName(QString::fromUtf8("actionE_xit"));
action_Load_Map = new QAction(Detection);
action_Load_Map->setObjectName(QString::fromUtf8("action_Load_Map"));
action_Connect = new QAction(Detection);
action_Connect->setObjectName(QString::fromUtf8("action_Connect"));
action_Disconnect = new QAction(Detection);
action_Disconnect->setObjectName(QString::fromUtf8("action_Disconnect"));
centralWidget = new QWidget(Detection);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
gridLayoutWidget = new QWidget(centralWidget);
gridLayoutWidget->setObjectName(QString::fromUtf8("gridLayoutWidget"));
gridLayoutWidget->setGeometry(QRect(0, 0, 721, 421));
gridLayout = new QGridLayout(gridLayoutWidget);
gridLayout->setSpacing(6);
gridLayout->setContentsMargins(11, 11, 11, 11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
gridLayout->setSizeConstraint(QLayout::SetNoConstraint);
gridLayout->setVerticalSpacing(5);
gridLayout->setContentsMargins(0, 0, 0, 0);
ugvFeedLabel = new QLabel(gridLayoutWidget);
ugvFeedLabel->setObjectName(QString::fromUtf8("ugvFeedLabel"));
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(ugvFeedLabel->sizePolicy().hasHeightForWidth());
ugvFeedLabel->setSizePolicy(sizePolicy);
gridLayout->addWidget(ugvFeedLabel, 1, 2, 1, 1);
connectionButton = new QCommandLinkButton(gridLayoutWidget);
connectionButton->setObjectName(QString::fromUtf8("connectionButton"));
gridLayout->addWidget(connectionButton, 0, 2, 1, 1);
uavFeedLabel = new QLabel(gridLayoutWidget);
uavFeedLabel->setObjectName(QString::fromUtf8("uavFeedLabel"));
sizePolicy.setHeightForWidth(uavFeedLabel->sizePolicy().hasHeightForWidth());
uavFeedLabel->setSizePolicy(sizePolicy);
uavFeedLabel->setMaximumSize(QSize(16777215, 16777215));
gridLayout->addWidget(uavFeedLabel, 1, 0, 1, 1);
ugvMapLabel = new QLabel(gridLayoutWidget);
ugvMapLabel->setObjectName(QString::fromUtf8("ugvMapLabel"));
QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(ugvMapLabel->sizePolicy().hasHeightForWidth());
ugvMapLabel->setSizePolicy(sizePolicy1);
gridLayout->addWidget(ugvMapLabel, 1, 3, 1, 1);
horizontalLayout_4 = new QHBoxLayout();
horizontalLayout_4->setSpacing(6);
horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
label_2 = new QLabel(gridLayoutWidget);
label_2->setObjectName(QString::fromUtf8("label_2"));
horizontalLayout_4->addWidget(label_2);
uavTakeoffLandButton = new QPushButton(gridLayoutWidget);
uavTakeoffLandButton->setObjectName(QString::fromUtf8("uavTakeoffLandButton"));
horizontalLayout_4->addWidget(uavTakeoffLandButton);
gridLayout->addLayout(horizontalLayout_4, 2, 0, 1, 1);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
label = new QLabel(gridLayoutWidget);
label->setObjectName(QString::fromUtf8("label"));
horizontalLayout_2->addWidget(label);
ugvSpeedLCD = new QLCDNumber(gridLayoutWidget);
ugvSpeedLCD->setObjectName(QString::fromUtf8("ugvSpeedLCD"));
ugvSpeedLCD->setFrameShape(QFrame::Box);
horizontalLayout_2->addWidget(ugvSpeedLCD);
gridLayout->addLayout(horizontalLayout_2, 4, 2, 1, 1);
horizontalLayout_6 = new QHBoxLayout();
horizontalLayout_6->setSpacing(6);
horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));
label_3 = new QLabel(gridLayoutWidget);
label_3->setObjectName(QString::fromUtf8("label_3"));
horizontalLayout_6->addWidget(label_3);
ugvSpeakerButton = new QPushButton(gridLayoutWidget);
//.........这里部分代码省略.........
示例7: createWidget
QWidget* WidgetStyle::createWidget(const QString& name)
{
if(name == "CheckBox")
{
QCheckBox* box = new QCheckBox("CheckBox");
box->setObjectName("CheckBox");
return setLayoutWidget({ box }, { 100, 30 });
}
else if(name == "ComboBox")
{
QComboBox* box = new QComboBox;
box->addItem("Item1");
box->addItem("Item3");
box->addItem("Item3");
box->setObjectName("ComboBox");
return setLayoutWidget({ box }, { 70, 30 });
}
else if(name == "DateEdit")
{
QDateEdit* date = new QDateEdit;
date->setObjectName("DateEdit");
return setLayoutWidget({ date }, { 110, 40 });
}
else if(name == "DateTimeEdit")
{
QDateTimeEdit* date = new QDateTimeEdit;
date->setObjectName("DateTimeEdit");
return setLayoutWidget({ date }, { 160, 30 });
}
else if(name == "Dialog")
{
QDialog* dialog = new QDialog;
dialog->setObjectName("Dialog");
return setLayoutWidget({ dialog }, { 160, 110 });
}
else if(name == "DockWidget") //?
{
QDockWidget* widget = new QDockWidget;
widget->setObjectName("DockWidget");
widget->resize(61, 22);
return widget;
}
else if(name == "DoubleSpinBox")
{
QDoubleSpinBox* box = new QDoubleSpinBox;
box->setObjectName("DoubleSpinBox");
return setLayoutWidget({ box }, { 90, 40 });
}
else if(name == "Frame") //??
{
QFrame* frame = new QFrame;
frame->setObjectName("Frame");
frame->resize(150, 100);
return frame;
}
else if(name == "GroupBox")
{
QGroupBox* box = new QGroupBox("GroupBox");
box->setObjectName("GroupBox");
return setLayoutWidget({ box }, { 160, 110 });
}
else if(name == "Label")
{
QLabel* label = new QLabel("Label");
label->setObjectName("Label");
return setLayoutWidget({ label }, { 40, 20});
}
else if(name == "LineEdit")
{
QLineEdit* line = new QLineEdit;
line->setObjectName("LineEdit");
return setLayoutWidget({ line }, { 30, 30 });
}
else if(name == "ListView") //??
{
QListView* view = new QListView;
view->setObjectName("ListView");
view->resize(71, 71);
return view;
}
else if(name == "ListWidget")
{
QListWidget* list = new QListWidget;
list->setObjectName("ListWidget");
for(int i = 0; i < 20; i++)
list->addItem(QString("Item %1").arg(i));
return setLayoutWidget({ list }, { 80, 80 });
}
else if(name == "MainWindow")
{
QMainWindow* window = new QMainWindow;
window->setObjectName("MainWindow");
return setLayoutWidget({ window }, { 160, 110 });
}
else if(name == "Menu")
{
QMenu* parentMenu = new QMenu;
parentMenu->setObjectName("Menu");
parentMenu->addMenu("Menu1");
QMenu* menu1 = parentMenu->addMenu("Menu2");
//.........这里部分代码省略.........
示例8: SetupUI
void EditorMainWindow::SetupUI(QMainWindow *MainWindow) {
setWindowIcon(*QtConfig::GetIcon("colorwheel.png"));
MainWindow->setWindowTitle("Sound Engine v0.2.3");
MainWindow->resize(1280, 720);
MainWindow->setDockOptions(QMainWindow::AnimatedDocks |
QMainWindow::AllowNestedDocks |
QMainWindow::AllowTabbedDocks);
MainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::TabPosition::North);
// ************************************************************************
// Load styling
ReloadStyleSheets();
// ************************************************************************
// File Picker
auto *picker = new FilePicker();
picker->setNameFilter("*.xml");
GUI::Set(QT_INSTACE::FILE_PICKER, (void*) picker);
// ************************************************************************
// Menu Bar
QMenuBar *menuBar = new QMenuBar(MainWindow);
menuBar->setObjectName(QStringLiteral("menuBar"));
menuBar->setGeometry(QRect(0, 0, 1051, 21));
MainWindow->setMenuBar(menuBar);
// Menu Entry
{
QMenu *menuEngine = new QMenu(menuBar);
menuEngine->setObjectName(QStringLiteral("menuEngine"));
menuEngine->setTitle("File");
menuBar->addAction(menuEngine->menuAction());
{
QAction *action = new QAction(MainWindow);
action->setText("Exit");
action->setIcon(*QtConfig::GetIcon("power.png"));
menuEngine->addAction(action);
QObject::connect(action, &QAction::triggered, this, &EditorMainWindow::close);
}
{
QAction *action = new QAction(MainWindow);
action->setText("Save As...");
action->setIcon(*QtConfig::GetIcon("memorycard.png"));
menuEngine->addAction(action);
QObject::connect(action, &QAction::triggered, this, [picker]() {
picker->OpenForSave();
});
QObject::connect(picker, &QFileDialog::fileSelected, this, [picker] (const QString & file) {
if (picker->IsSaving()) {
CSoundEditor::GetScene()->SaveSceneAs(file.toStdString().c_str());
}
});
}
}
// Menu Entry
{
QMenu *menu = new QMenu(menuBar);
menu->setTitle("Scene");
menuBar->addAction(menu->menuAction());
// Submenu buttons
QAction *action = new QAction(MainWindow);
action->setText("Clear Scene");
action->setIcon(*QtConfig::GetIcon("denied.png"));
menu->addAction(action);
QObject::connect(action, &QAction::triggered, this, []() {
CSoundEditor::GetScene()->Clear();
GUI::Get<SceneWindow>(QT_INSTACE::SCENE_EDITOR)->Clear();
});
}
// Menu Entry
{
QMenu *menu = new QMenu(menuBar);
menu->setTitle("Tools");
menuBar->addAction(menu->menuAction());
// Submenu buttons
{
QAction *action = new QAction(MainWindow);
action->setText("Reload StyleSheets");
action->setIcon(*QtConfig::GetIcon("cmyk.png"));
menu->addAction(action);
QObject::connect(action, &QAction::triggered, this, &EditorMainWindow::ReloadStyleSheets);
}
//.........这里部分代码省略.........
示例9: setupUi
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(999, 913);
actionAbout = new QAction(MainWindow);
actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
actionAtlas = new QAction(MainWindow);
actionAtlas->setObjectName(QString::fromUtf8("actionAtlas"));
actionMapping = new QAction(MainWindow);
actionMapping->setObjectName(QString::fromUtf8("actionMapping"));
actionLibrary = new QAction(MainWindow);
actionLibrary->setObjectName(QString::fromUtf8("actionLibrary"));
actionToolbox = new QAction(MainWindow);
actionToolbox->setObjectName(QString::fromUtf8("actionToolbox"));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
gridLayout = new QGridLayout(centralwidget);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
mainSizer = new QGridLayout();
mainSizer->setObjectName(QString::fromUtf8("mainSizer"));
mainSizer->setVerticalSpacing(14);
mainSizer->setContentsMargins(0, -1, -1, -1);
renderFrame = new QFrame(centralwidget);
renderFrame->setObjectName(QString::fromUtf8("renderFrame"));
renderFrame->setMinimumSize(QSize(800, 600));
renderFrame->setFrameShape(QFrame::Box);
renderFrame->setFrameShadow(QFrame::Raised);
mainSizer->addWidget(renderFrame, 0, 0, 1, 1);
gridLayout->addLayout(mainSizer, 0, 0, 1, 1);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 999, 21));
menuFile = new QMenu(menubar);
menuFile->setObjectName(QString::fromUtf8("menuFile"));
menuTools = new QMenu(menubar);
menuTools->setObjectName(QString::fromUtf8("menuTools"));
menuAbout = new QMenu(menubar);
menuAbout->setObjectName(QString::fromUtf8("menuAbout"));
menuWindows = new QMenu(menubar);
menuWindows->setObjectName(QString::fromUtf8("menuWindows"));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);
menubar->addAction(menuFile->menuAction());
menubar->addAction(menuTools->menuAction());
menubar->addAction(menuWindows->menuAction());
menubar->addAction(menuAbout->menuAction());
menuTools->addAction(actionAtlas);
menuTools->addAction(actionMapping);
menuAbout->addAction(actionAbout);
menuWindows->addAction(actionLibrary);
menuWindows->addAction(actionToolbox);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi