本文整理汇总了C++中QToolButton::setMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::setMenu方法的具体用法?C++ QToolButton::setMenu怎么用?C++ QToolButton::setMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::setMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createToolBars
void MainWindow::createToolBars()
{
webToolBar = addToolBar(tr("Web Tool Bar"));
webToolBar->addAction(publishAct);
editToolBar = addToolBar(tr("Edit Tool Bar"));
editToolBar->addAction(undoAct);
editToolBar->addAction(redoAct);
QToolButton *editButton = new QToolButton(editToolBar);
QMenu *editList = new QMenu(editButton);
editList->addAction(cutAct);
editList->addAction(copyAct);
editList->addAction(pasteAct);
editButton->setPopupMode(QToolButton::InstantPopup);
editButton->setIcon(cutAct->icon());
editButton->setMenu(editList);
editToolBar->addWidget(editButton);
textToolBar = addToolBar(tr("Text Tool Bar"));
secList = new HeadingComboBox(this);
textToolBar->addWidget(secList);
textToolBar->addAction(textBoldAct);
textToolBar->addAction(textItalicAct);
textToolBar->addAction(textUnderlineAct);
textToolBar->addAction(textStrikeoutAct);
textToolBar->addAction(textFontAct);
textToolBar->addAction(textColorAct);
textToolBar->addAction(textBackgroundColorAct);
textToolBar->addSeparator();
if(QApplication::isLeftToRight()) {
textToolBar->addAction(alignLeftAct);
textToolBar->addAction(alignCenterAct);
textToolBar->addAction(alignRightAct);
} else {
textToolBar->addAction(alignRightAct);
textToolBar->addAction(alignCenterAct);
textToolBar->addAction(alignLeftAct);
}
textToolBar->addAction(alignJustifyAct);
textToolBar->addSeparator();
textToolBar->addAction(bulletListAct);
textToolBar->addAction(numberedListAct);
QToolButton *tableButton = new QToolButton(editToolBar);
tableButton->setMenu(createTableMenu(tableButton));
tableButton->setPopupMode(QToolButton::InstantPopup);
tableButton->setIcon(tableInsertAct->icon());
tableButton->setToolTip(tr("Table"));
textToolBar->addWidget(tableButton);
}
示例2: createWidget
QWidget* ToolAction::createWidget( QWidget *parent )
{
QToolBar *toolBar = qobject_cast< QToolBar * >( parent );
if ( !toolBar )
return 0;
QToolButton *button = new QToolButton( toolBar );
button->setAutoRaise( true );
button->setFocusPolicy( Qt::NoFocus );
button->setIconSize( toolBar->iconSize() );
button->setToolButtonStyle( toolBar->toolButtonStyle() );
button->setPopupMode( QToolButton::DelayedPopup );
button->setMenu( new QMenu( button ) );
button->setCheckable( true );
connect(toolBar, &QToolBar::iconSizeChanged, button, &QToolButton::setIconSize);
connect(toolBar, &QToolBar::toolButtonStyleChanged, button, &QToolButton::setToolButtonStyle);
connect(button, &QToolButton::triggered, toolBar, &QToolBar::actionTriggered);
connect( button->menu(), &QMenu::triggered, this, &ToolAction::slotNewDefaultAction );
m_buttons.append( button );
if ( !m_actions.isEmpty() )
{
button->setDefaultAction( m_actions.first() );
foreach ( QAction *action, m_actions )
{
button->menu()->addAction( action );
if ( action->isChecked() )
button->setDefaultAction( action );
}
示例3: build
void BookmarksToolBar::build()
{
clear();
for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) {
QModelIndex idx = m_bookmarksModel->index(i, 0, m_root);
if (m_bookmarksModel->hasChildren(idx)) {
QToolButton *button = new QToolButton(this);
button->setPopupMode(QToolButton::InstantPopup);
button->setArrowType(Qt::DownArrow);
button->setText(idx.data().toString());
ModelMenu *menu = new ModelMenu(this);
connect(menu, SIGNAL(activated(QModelIndex)),
this, SLOT(activated(QModelIndex)));
menu->setModel(m_bookmarksModel);
menu->setRootIndex(idx);
menu->addAction(new QAction(menu));
button->setMenu(menu);
button->setToolButtonStyle(Qt::ToolButtonTextOnly);
QAction *a = addWidget(button);
a->setText(idx.data().toString());
} else {
QAction *action = addAction(idx.data().toString());
action->setData(idx.data(BookmarksModel::UrlRole));
}
}
}
示例4: QToolBar
BottomPanelChooser::BottomPanelChooser(
BottomPanel* bottomPanel,
QWidget *parent)
: QToolBar(parent)
, _bottomPanel(bottomPanel)
, _displayMenu(NULL)
, _menuAction(NULL)
, _openMap(new QSignalMapper(this))
, _displayMap(new QSignalMapper(this))
{
this->setObjectName("DarkToolBar");
_bottomPanel->installEventFilter(this);
_displayMenu = new QMenu;
QToolButton* toolButton = new QToolButton;
//toolButton->setIcon(QIcon());
toolButton->setMenu(_displayMenu);
toolButton->setPopupMode(QToolButton::InstantPopup);
_menuAction = this->QToolBar::addWidget(toolButton);
_menuAction->setVisible(false);
connect(_openMap, SIGNAL(mapped(QWidget*)), this, SLOT(xOnOpenTriggered(QWidget*)));
connect(_displayMap, SIGNAL(mapped(QWidget*)), this, SLOT(xOnDisplayTriggered(QWidget*)));
}
示例5: createWidget
Core::NavigationView TestNavigationWidgetFactory::createWidget()
{
Core::NavigationView view;
TestSelector *ptw = new TestSelector();
ptw->rescan();
view.widget = ptw;
QToolButton *filter = new QToolButton;
filter->setIcon(QIcon(Core::Constants::ICON_FILTER));
filter->setToolTip(tr("Filter tree"));
filter->setPopupMode(QToolButton::InstantPopup);
QMenu *filterMenu = new QMenu(filter);
filterMenu->addAction(ptw->m_componentViewMode);
filterMenu->addAction(ptw->m_showUnitTests);
filterMenu->addAction(ptw->m_showIntegrationTests);
filterMenu->addAction(ptw->m_showPerformanceTests);
filterMenu->addAction(ptw->m_showSystemTests);
filter->setMenu(filterMenu);
QToolButton *newTest = new QToolButton;
newTest->setIcon(QIcon(":/core/images/filenew.png"));
newTest->setToolTip(tr("New test"));
newTest->setPopupMode(QToolButton::InstantPopup);
QObject::connect(newTest, SIGNAL(clicked()), ptw,
SLOT(testInsertUnitOrSystemTest()), Qt::DirectConnection);
view.dockToolBarWidgets << filter << newTest;
return view;
}
示例6: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// create TabListMenu
QSint::TabListMenu *tabMenu = new QSint::TabListMenu(this);
// assing ui->tabWidget to the tabMenu
tabMenu->setTabs(ui->tabWidget);
// create corner button
QToolButton *tbTabsDropList = new QToolButton(this);
tbTabsDropList->setArrowType(Qt::DownArrow);
tbTabsDropList->setPopupMode(QToolButton::InstantPopup);
ui->tabWidget->setCornerWidget(tbTabsDropList);
// assing tabMenu to the tbTabsDropList
tbTabsDropList->setMenu(tabMenu);
// just for demo: connect cbUseIcons checkbox to the tabMenu's setAllowIcons() slot
connect(ui->cbUseIcons, SIGNAL(toggled(bool)), tabMenu, SLOT(setAllowIcons(bool)));
}
示例7: display
dspOrderActivityByProject::dspOrderActivityByProject(QWidget* parent, const char*, Qt::WindowFlags fl)
: display(parent, "dspOrderActivityByProject", fl)
{
setupUi(optionsWidget());
setWindowTitle(tr("Order Activity by Project"));
setListLabel(tr("Orders"));
setReportName("OrderActivityByProject");
setMetaSQLOptions("orderActivityByProject", "detail");
setUseAltId(true);
_run = false;
list()->addColumn(tr("Name"), _itemColumn, Qt::AlignLeft, true, "name" );
list()->addColumn(tr("Status"), _orderColumn, Qt::AlignLeft, true, "status" );
list()->addColumn(tr("Item #"), _itemColumn, Qt::AlignLeft, true, "item" );
list()->addColumn(tr("Description"), -1 , Qt::AlignLeft, true, "descrip" );
list()->addColumn(tr("Account/Customer"), -1 , Qt::AlignLeft, true, "customer" );
list()->addColumn(tr("Contact"), -1 , Qt::AlignLeft, false, "contact" );
list()->addColumn(tr("City"), -1 , Qt::AlignLeft, false, "city" );
list()->addColumn(tr("State"), -1 , Qt::AlignLeft, false, "state" );
list()->addColumn(tr("Qty"), _qtyColumn, Qt::AlignRight, true, "qty" );
list()->addColumn(tr("UOM"), _uomColumn, Qt::AlignLeft, true, "uom" );
list()->addColumn(tr("Value"), _qtyColumn, Qt::AlignRight, true, "value" );
list()->addColumn(tr("Due Date"), _dateColumn, Qt::AlignRight, true, "due" );
list()->addColumn(tr("Assigned"), _dateColumn, Qt::AlignRight, true, "assigned" );
list()->addColumn(tr("Started"), _dateColumn, Qt::AlignRight, true, "started" );
list()->addColumn(tr("Completed"), _dateColumn, Qt::AlignRight, true, "completed" );
list()->addColumn(tr("Hrs. Budget"), _qtyColumn, Qt::AlignRight, true, "hrs_budget" );
list()->addColumn(tr("Hrs. Actual"), _qtyColumn, Qt::AlignRight, true, "hrs_actual" );
list()->addColumn(tr("Hrs. Balance"), _qtyColumn, Qt::AlignRight, true, "hrs_balance" );
list()->addColumn(tr("Exp. Budget"), _priceColumn, Qt::AlignRight, true, "exp_budget" );
list()->addColumn(tr("Exp. Actual"), _priceColumn, Qt::AlignRight, true, "exp_actual" );
list()->addColumn(tr("Exp. Balance"), _priceColumn, Qt::AlignRight, true, "exp_balance" );
list()->setPopulateLinear(true);
disconnect(newAction(), SIGNAL(triggered()), this, SLOT(sNew()));
connect(newAction(), SIGNAL(triggered()), this, SLOT(sNewProjectTask()));
connect(_showSo, SIGNAL(checked()), this, SLOT(sFillList()));
connect(_showPo, SIGNAL(checked()), this, SLOT(sFillList()));
connect(_showWo, SIGNAL(checked()), this, SLOT(sFillList()));
QToolButton * newBtn = (QToolButton*)toolBar()->widgetForAction(newAction());
newBtn->setPopupMode(QToolButton::MenuButtonPopup);
QAction *menuItem;
QMenu * newMenu = new QMenu;
menuItem = newMenu->addAction(tr("Task"), this, SLOT(sNewProjectTask()));
menuItem->setEnabled(_privileges->check("MaintainAllProjects"));
newMenu->addSeparator();
menuItem = newMenu->addAction(tr("Sales Order"), this, SLOT(sNewSalesOrder()));
menuItem->setEnabled(_privileges->check("MaintainSalesOrders"));
menuItem = newMenu->addAction(tr("Purchase Order"), this, SLOT(sNewPurchaseOrder()));
menuItem->setEnabled(_privileges->check("MaintainPurchaseOrders"));
menuItem = newMenu->addAction(tr("Work Order"), this, SLOT(sNewWorkOrder()));
menuItem->setEnabled(_privileges->check("MaintainWorkOrders"));
newBtn->setMenu(newMenu);
}
示例8: setToolMenu
void ToolDockWidget::setToolMenu(QMenu *menu)
{
QToolButton *btn = new QToolButton;
btn->setPopupMode(QToolButton::InstantPopup);
btn->setMenu(menu);
m_toolBar->insertWidget(m_closeAct,btn);
}
示例9: QMainWindow
ViewWindow::ViewWindow( Record::Server& server, QWidget* parent, Qt::WFlags flags )
: QMainWindow( parent, flags )
, server( server )
, pShow1x1( new QAction( QIcon( ":/icons/1x1.png" ), "1x1", this ) )
, pShow2x1( new QAction( QIcon( ":/icons/2x1.png" ), "2x1", this ) )
, pShow1x2( new QAction( QIcon( ":/icons/1x2.png" ), "1x2", this ) )
, pShow2x2( new QAction( QIcon( ":/icons/2x2.png" ), "2x2", this ) )
{
QToolBar* toolbar = addToolBar( "View" );
toolbar->setMovable( false );
toolbar->addAction( pShow1x1 );
toolbar->addAction( pShow2x1 );
toolbar->addAction( pShow1x2 );
toolbar->addAction( pShow2x2 );
connect( pShow1x1, SIGNAL( triggered() ), this, SLOT( show1x1() ) );
connect( pShow2x1, SIGNAL( triggered() ), this, SLOT( show2x1() ) );
connect( pShow1x2, SIGNAL( triggered() ), this, SLOT( show1x2() ) );
connect( pShow2x2, SIGNAL( triggered() ), this, SLOT( show2x2() ) );
pShow1x1->setCheckable( true );
pShow2x1->setCheckable( true );
pShow1x2->setCheckable( true );
pShow2x2->setCheckable( true );
// -----------------------------------------------------------------
QToolButton* pAcquireButton = new QToolButton( toolbar );
QMenu* pAcquireMenu = new QMenu( pAcquireButton );
pAcquireButton->setMenu( pAcquireMenu );
pAcquireButton->setPopupMode( QToolButton::InstantPopup );
pAcquireButton->setText( "&Acquire" );
pAcquireButton->setMinimumHeight( 32 );
toolbar->setIconSize( QSize( 24, 24 ) );
toolbar->addSeparator();
toolbar->addWidget( pAcquireButton );
for( auto it = ComponentRegister::instance().factories.begin();
it != ComponentRegister::instance().factories.end();
++it )
{
ComponentLauncher* launcher = new ComponentLauncher( **it, *this, this );
pAcquireMenu->addAction( launcher->action );
}
// -----------------------------------------------------------------
areaArray = new EmbedAreaArray();
this->setCentralWidget( areaArray );
// -----------------------------------------------------------------
componentWindowfactory.reset( new ViewWindowComponentWindowFactory( *this, *areaArray ) );
pShow1x1->trigger();
}
示例10: selectButton
QToolButton* AppearanceDialog::selectButton(int width, int height, QString toolTip) {
QToolButton* button = new QToolButton(this);
button->setToolTip(toolTip);
button->setToolButtonStyle(Qt::ToolButtonTextOnly);
button->setMenu(new QMenu(button));
button->setMinimumWidth(width);
button->setMinimumHeight(height);
return button;
}
示例11: getToolbars
void QCastViewGL::getToolbars(CPtrVector<QToolBar>& toolbars)
{
if (! pView) return;
CPtrVector<cogx::display::CDisplayCamera> cameras;
pView->getCameras(cameras);
if (cameras.size() < 1) return;
// pBar->parent will be reset in QViewContainer
QToolBar *pBar = new QToolBar(QString::fromStdString(pView->m_id), this);
if (pBar) {
unsigned int nc = cameras.size();
if (nc > 3) nc = 3;
cogx::display::CDisplayCamera* pCamera;
for (unsigned int i= 0; i < nc; i++) {
QToolButton *pBut = new QToolButton(pBar);
pCamera = cameras[i];
QString text = QString::fromStdString(pCamera->name);
QAction* pAct = new QAction(QIcon(":/toolButton/camera-photo.png"), text, pBut);
pAct->setToolTip("Select Camera: " + text);
pAct->setData(qVariantFromValue((void*)pCamera));
pBut->setDefaultAction(pAct);
pBar->addWidget(pBut);
pBar->connect(pAct, SIGNAL(triggered()), this, SLOT(onCameraChangeAction()));
// With more than 3 cameras things become complicated...
if (i == 2 && cameras.size() > 2) {
QAction *pPopAct;
QMenu *pMenu = new QMenu(pBut); // parent MUST be button, see onCameraChangeAction
pBut->setMenu(pMenu);
pBut->setPopupMode(QToolButton::MenuButtonPopup);
for (unsigned int j = 0; j < cameras.size(); j++) {
if (i == j) {
pMenu->addAction(pAct);
pAct->setParent(pMenu); // parent MUST be menu, see onCameraChangeAction
}
else {
pCamera = cameras[j];
text = QString::fromStdString(pCamera->name);
pPopAct = pMenu->addAction(QIcon(":/toolButton/camera-photo.png"), text);
pPopAct->setData(qVariantFromValue((void*)pCamera));
pPopAct->setToolTip("Select Camera: " + text);
pBar->connect(pPopAct, SIGNAL(triggered()), this, SLOT(onCameraChangeAction()));
}
}
if (0) {
text = "TODO: Configure camera buttons...";
pPopAct = pMenu->addAction(QIcon(":/toolButton/camera-photo.png"), text);
pBar->connect(pPopAct, SIGNAL(triggered()), this, SLOT(onActConfigureCameras()));
}
}
}
toolbars.push_back(pBar);
}
}
示例12: InitTitleBar
void FramelessDlg::InitTitleBar()
{
QVBoxLayout* layout = qobject_cast<QVBoxLayout*>(this->layout());
m_closeBtn = new QToolButton(this);
QToolButton* minBtn = new QToolButton(this);
QToolButton* menuBtn = new QToolButton(this);
m_subTitle = new QLabel(this);
m_subTitle->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_closeBtn->setObjectName("closeBtn");
minBtn->setObjectName("minBtn");
menuBtn->setObjectName("menuBtn");
m_subTitle->setObjectName("subTitle");
menuBtn->setPopupMode(QToolButton::InstantPopup);
m_menu = new QMenu(this);
menuBtn->setMenu(m_menu);
m_closeBtn->setFixedSize(27, 22);
minBtn->setFixedSize(27, 22);
menuBtn->setFixedSize(27, 22);
m_subTitle->setFixedSize(400, 25);
connect(m_closeBtn, SIGNAL(clicked()), this, SLOT(reject()));
connect(m_closeBtn, SIGNAL(clicked()), this, SLOT(close()));
connect(minBtn, SIGNAL(clicked()), this, SLOT(showMinimized()));
QFrame* tb = new QFrame(this);
tb->setObjectName("titleBar");
QHBoxLayout* tbLayout = new QHBoxLayout;
m_title = new QLabel(this);
m_title->setObjectName("label_title");
m_title->setFixedSize(300, 25);
tbLayout->addWidget(m_title);
tbLayout->addSpacerItem(new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Fixed));
if ( m_flag & SUB_TITLE )
tbLayout->addWidget(m_subTitle);
if ( m_flag & MENU_BUTTON )
tbLayout->addWidget(menuBtn);
if ( m_flag & MIN_BUTTON )
tbLayout->addWidget(minBtn);
if ( m_flag & CLOSE_BUTTON )
tbLayout->addWidget(m_closeBtn);
tb->setLayout(tbLayout);
layout->addWidget(tb);
}
示例13: rebuildRecentFileMenu
void FileToolBar::rebuildRecentFileMenu()
{
QToolButton* tb = dynamic_cast<QToolButton*>(widgetForAction(parent->scrActions["fileOpen"]));
QMenu *m=new QMenu(this);
ScrAction *recentFileAction;
foreach (recentFileAction, parent->scrRecentFileActions)
m->addAction(recentFileAction);
tb->setMenu(m);
// tb->setPopupMode(QToolButton::MenuButtonPopup);
tb->setPopupMode(QToolButton::DelayedPopup);
}
示例14: setupMenus
void AudioLevelsWidget::setupMenus()
{
this->contextMenuAudioLevelsDropdown = new QMenu(this);
this->contextMenuAudioLevelsDropdown->setTitle("Dropdown");
this->expandCollapseAction = this->contextMenuAudioLevelsDropdown->addAction(/*QIcon(":/Graphics/Images/Collapse.png"),*/ "Collapse", this, SLOT(toggleExpandCollapse()));
QToolButton* toolButtonAudioLevelsDropdown = new QToolButton(this);
toolButtonAudioLevelsDropdown->setObjectName("toolButtonAudioLevelsDropdown");
toolButtonAudioLevelsDropdown->setMenu(this->contextMenuAudioLevelsDropdown);
toolButtonAudioLevelsDropdown->setPopupMode(QToolButton::InstantPopup);
this->tabWidgetAudioLevels->setCornerWidget(toolButtonAudioLevelsDropdown);
//this->tabWidgetPreview->setTabIcon(0, QIcon(":/Graphics/Images/TabSplitter.png"));
}
示例15: addMenu
void MainWindow::addMenu(QMenu *menu)
{
QToolButton *toolButton = new QToolButton(_toolBar);
toolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
toolButton->setText(menu->title());
toolButton->setMenu(menu);
toolButton->setPopupMode(QToolButton::InstantPopup);
toolButton->setStyleSheet("QToolButton::menu-indicator { width: 0px; }");
_toolBar->insertWidget(_spacerAction, toolButton);
connect(toolButton, SIGNAL(triggered(QAction*)), this, SIGNAL(signalActionTriggered(QAction*)));
}