本文整理汇总了C++中QMenuBar::setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::setStyleSheet方法的具体用法?C++ QMenuBar::setStyleSheet怎么用?C++ QMenuBar::setStyleSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::setStyleSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMenu
void ChessWindow::createMenu() {
QMenuBar *menuBar = ui_.menubar;
menuBar->setStyleSheet("QMenuBar::item {background-color: #ffffe7; border-radius: 1px; border: 1px solid #74440e; color: black;"
"spacing: 10px; padding: 1px 4px; background: transparent; }"
"QMenuBar::item:selected { background-color: #ffeeaf; color: black; }"
"QMenuBar::item:pressed { background: #ffeeaf; color: black; }");
QAction *loadAction = new QAction(tr("Load game"), menuBar);
QAction *saveAction = new QAction(tr("Save game"), menuBar);
QAction *quitAction = new QAction(tr("Quit"), menuBar);
loseAction = new QAction(tr("Resign"), menuBar);
QAction *soundAction = new QAction(tr("Enable sound"),menuBar);
soundAction->setCheckable(true);
soundAction->setChecked(enabledSound);
QMenu *fileMenu = menuBar->addMenu(tr("File"));
QMenu *gameMenu = menuBar->addMenu(tr("Game"));
fileMenu->addAction(loadAction);
fileMenu->addAction(saveAction);
fileMenu->addSeparator();
fileMenu->addAction(quitAction);
gameMenu->addAction(loseAction);
gameMenu->addSeparator();
gameMenu->addAction(soundAction);
connect(loadAction, SIGNAL(triggered()), this, SLOT(load()));
connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()), Qt::QueuedConnection);
connect(loseAction, SIGNAL(triggered()), this, SIGNAL(lose()));
connect(soundAction, SIGNAL(triggered(bool)), this, SIGNAL(toggleEnableSound(bool)));
}
示例2: fillToolBars
///
/// Public Funcitons
///
//!
//! Fills the given tool bars with actions for the TableViewPanel view.
//!
//! \param mainToolBar The main tool bar to fill with actions.
//! \param panelToolBar The panel tool bar to fill with actions.
//!
void TableViewPanel::fillToolBars ( QToolBar *mainToolBar, QToolBar *panelToolBar )
{
// Temp
QAction *ui_descriptionAction;
ui_descriptionAction = new QAction(this);
ui_descriptionAction->setObjectName(QString::fromUtf8("ui_descriptionAction"));
ui_descriptionAction->setCheckable(true);
QIcon icon1;
icon1.addFile(QString::fromUtf8(":/infoIcon"), QSize(), QIcon::Normal, QIcon::Off);
ui_descriptionAction->setIcon(icon1);
ui_descriptionAction->setToolTip("Show Description");
connect(ui_descriptionAction, SIGNAL(toggled(bool)), this, SLOT(showDiscription(bool)));
// Column visibility select control
// Place holder for drop down to select which columns of table are visible
// This should be populated with column names
QAction *visibilityAct = new QAction(tr("&Select Columns..."), this);
visibilityAct->setStatusTip(tr("Select columns for visibility..."));
connect(visibilityAct, SIGNAL(triggered()), this, SLOT());
QMenu *visibilityMenu = new QMenu();
visibilityMenu->addAction(visibilityAct);
visibilityMenu->addSeparator();
QString menuStyleSheet (
"QMenuBar {"
" border: none;"
" margin: 0px;"
" padding: 0px;"
" background: none;"
"}"
"QMenuBar::item {"
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a5a5a5, stop:0.2 #999999, stop:0.8 #b0b0b0, stop:1 #555555);"
" color: #000000;"
" border: 1px solid #323232"
" border-radius: 5px;"
"}"
"QMenuBar::item:selected {"
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);"
" color: #000000;"
" border: 1px solid #222222"
" border-radius: 5px;"
"}"
"QMenuBar::item:pressed {"
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #a6a6a6, stop:1 #8a8a8a);"
" color: #000000;"
" border: 1px solid #222222"
" border-radius: 5px;"
"}"
);
QMenuBar *visibilityMenuBar = new QMenuBar();
visibilityMenuBar->setMinimumWidth(50);
visibilityMenuBar->setStyleSheet(menuStyleSheet);
visibilityMenuBar->addMenu(visibilityMenu);
visibilityMenuBar->addAction(visibilityAct);
// Search control
// Keyword search highlights rows
QLineEdit *searchField = new QLineEdit();
searchField->setMaximumWidth(200);
mainToolBar->addAction(ui_descriptionAction);
mainToolBar->addSeparator();
mainToolBar->addWidget(visibilityMenuBar);
mainToolBar->addSeparator();
mainToolBar->addWidget(searchField);
}