本文整理汇总了C++中QToolButton::setPopupMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::setPopupMode方法的具体用法?C++ QToolButton::setPopupMode怎么用?C++ QToolButton::setPopupMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::setPopupMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setActionGroup
void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList<QAction*>& group)
{
// See also ActionGroup::addTo()
QList<QWidget*> widgets = action->associatedWidgets();
for (QList<QWidget*>::iterator it = widgets.begin(); it != widgets.end(); ++it) {
QToolButton* tb = qobject_cast<QToolButton*>(*it);
if (tb) {
QMenu* menu = tb->menu();
if (!menu) {
tb->setPopupMode(QToolButton::MenuButtonPopup);
tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton"));
QMenu* menu = new QMenu(tb);
menu->addActions(group);
tb->setMenu(menu);
}
}
}
}
示例2: 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);
QVariant variant;
variant.setValue(idx);
QString title = idx.data().toString();
bool folder = m_bookmarksModel->hasChildren(idx);
QToolButton *button = 0;
if (folder)
button = new QToolButton(this);
else
button = new BookmarkToolButton(this);
button->setPopupMode(QToolButton::InstantPopup);
button->setToolButtonStyle(Qt::ToolButtonTextOnly);
QAction *action = addWidget(button);
action->setData(variant);
action->setText(title);
button->setDefaultAction(action);
if (folder) {
button->setArrowType(Qt::DownArrow);
ModelMenu *menu = new BookmarksMenu(this);
menu->setModel(m_bookmarksModel);
menu->setRootIndex(idx);
menu->addAction(new QAction(menu));
action->setMenu(menu);
connect(menu, SIGNAL(openUrl(const QUrl &, const QString &)),
this, SIGNAL(openUrl(const QUrl &, const QString &)));
connect(menu, SIGNAL(openUrl(const QUrl &, TabWidget::OpenUrlIn, const QString &)),
this, SIGNAL(openUrl(const QUrl &, TabWidget::OpenUrlIn, const QString &)));
} else {
connect(action, SIGNAL(triggered()),
this, SLOT(openBookmark()));
}
}
示例3: QLineEdit
FilterWidget::FilterWidget(QWidget *parent)
: QLineEdit(parent)
, m_patternGroup(new QActionGroup(this))
{
setClearButtonEnabled(true);
connect(this, SIGNAL(textChanged(QString)), this, SIGNAL(filterChanged()));
QMenu *menu = new QMenu(this);
m_caseSensitivityAction = menu->addAction(tr("Case Sensitive"));
m_caseSensitivityAction->setCheckable(true);
connect(m_caseSensitivityAction, SIGNAL(toggled(bool)), this, SIGNAL(filterChanged()));
menu->addSeparator();
m_patternGroup->setExclusive(true);
QAction *patternAction = menu->addAction("Fixed String");
patternAction->setData(QVariant(int(QRegExp::FixedString)));
patternAction->setCheckable(true);
patternAction->setChecked(true);
m_patternGroup->addAction(patternAction);
patternAction = menu->addAction("Regular Expression");
patternAction->setCheckable(true);
patternAction->setData(QVariant(int(QRegExp::RegExp2)));
m_patternGroup->addAction(patternAction);
patternAction = menu->addAction("Wildcard");
patternAction->setCheckable(true);
patternAction->setData(QVariant(int(QRegExp::Wildcard)));
m_patternGroup->addAction(patternAction);
connect(m_patternGroup, SIGNAL(triggered(QAction*)), this, SIGNAL(filterChanged()));
const QIcon icon = QIcon(QPixmap(":/images/find.png"));
QToolButton *optionsButton = new QToolButton;
#ifndef QT_NO_CURSOR
optionsButton->setCursor(Qt::ArrowCursor);
#endif
optionsButton->setFocusPolicy(Qt::NoFocus);
optionsButton->setStyleSheet("* { border: none; }");
optionsButton->setIcon(icon);
optionsButton->setMenu(menu);
optionsButton->setPopupMode(QToolButton::InstantPopup);
QWidgetAction *optionsAction = new QWidgetAction(this);
optionsAction->setDefaultWidget(optionsButton);
addAction(optionsAction, QLineEdit::LeadingPosition);
}
示例4: addToolbarItem
void ZLQtApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
QToolBar *tb = toolbar(type(*item));
QAction *action = 0;
switch (item->type()) {
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
action = new ZLQtToolBarAction(this, (ZLToolbar::AbstractButtonItem&)*item);
tb->addAction(action);
break;
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
QToolButton *button = new QToolButton(tb);
button->setFocusPolicy(Qt::NoFocus);
button->setDefaultAction(new ZLQtToolBarAction(this, buttonItem));
button->setMenu(new QMenu(button));
button->setPopupMode(QToolButton::MenuButtonPopup);
action = tb->addWidget(button);
myMenuButtons[&buttonItem] = button;
shared_ptr<ZLPopupData> popupData = buttonItem.popupData();
myPopupIdMap[&buttonItem] =
popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);
break;
}
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::SEARCH_FIELD:
{
ZLToolbar::ParameterItem &textFieldItem =
(ZLToolbar::ParameterItem&)*item;
LineEditParameter *para = new LineEditParameter(tb, *this, textFieldItem);
addVisualParameter(textFieldItem.parameterId(), para);
action = para->action();
break;
}
case ZLToolbar::Item::SEPARATOR:
action = tb->addSeparator();
break;
}
if (action != 0) {
myActions[&*item] = action;
}
}
示例5: createToolBars
void GTMainWindow::createToolBars(){
fileToolBar = addToolBar(tr("File"));
fileToolBar->setFloatable(false);
fileToolBar->setMovable(false);
fileToolBar->setIconSize(QSize(25, 25));
fileMenu = new QMenu();
fileMenu->addAction(newAct);
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
fileMenu->addAction(closeAct);
fileMenu->addSeparator();
fileMenu->addAction(exitAct);
QToolButton* toolButton = new QToolButton();
toolButton->setIcon(QIcon(":/Resources/gt_icon.png"));
toolButton->setMenu(fileMenu);
toolButton->setPopupMode(QToolButton::InstantPopup);
fileToolBar->addWidget(toolButton);
fileToolBar->addSeparator();
fileToolBar->addAction(newAct);
fileToolBar->addAction(openAct);
fileToolBar->addAction(saveAct);
fileToolBar->addAction(closeAct);
fileToolBar->addSeparator();
//ui->gtStatusWidget->setParent(fileToolBar);
//ui->gtStatusWidget->setVisible(false);
//fileToolBar->addWidget(ui->gtStatusWidget);
/*editToolBar = addToolBar(tr("Edit"));
editToolBar->addAction(cutAct);
editToolBar->addAction(copyAct);
editToolBar->addAction(pasteAct);*/
}
示例6: createMenu
void SideDockWidget::createMenu(Qt::DockWidgetArea /*area*/)
{
// QMenu *moveMenu = new QMenu(tr("Move To"),this);
// QAction *act = new QAction(tr("OutputBar"),this);
// act->setData(area);
// moveMenu->addAction(act);
// connect(act,SIGNAL(triggered()),this,SLOT(moveAction()));
m_menu = new QMenu(this);
QToolButton *btn = new QToolButton(m_toolBar);
btn->setPopupMode(QToolButton::InstantPopup);
btn->setIcon(QIcon("icon:images/movemenu.png"));
btn->setMenu(m_menu);
btn->setText(tr("SideBar"));
btn->setToolTip(tr("Show SideBar"));
btn->setStyleSheet("QToolButton::menu-indicator {image: none;}");
m_toolBar->insertWidget(m_closeAct,btn);
}
示例7: FAILED
static void
replaceButtons (QToolBar* dest, QWidget* src) {
if (src == NULL || dest == NULL)
FAILED ("replaceButtons expects valid objects");
dest->setUpdatesEnabled (false);
bool visible = dest->isVisible();
if (visible) dest->hide(); //TRICK: to avoid flicker of the dest widget
replaceActions (dest, src);
QList<QObject*> list = dest->children();
for (int i = 0; i < list.count(); ++i) {
QToolButton* button = qobject_cast<QToolButton*> (list[i]);
if (button) {
button->setPopupMode (QToolButton::InstantPopup);
button->setStyle (qtmstyle());
}
}
if (visible) dest->show(); //TRICK: see above
dest->setUpdatesEnabled (true);
}
示例8: QToolBar
GuiFindToolBar::GuiFindToolBar(GuiMainWindow *p)
: QToolBar(p),
mainWnd(p)
{
searchedText = new QLineEdit();
findTextFlag = false;
currentRow = -1;
currentCol = -1;
pageStartPosition = 0;
QToolButton *b;
currentSearchedText = "";
addWidget(searchedText);
searchedText->installEventFilter(this);
b = new QToolButton(this);
b->setText("Up");
connect(b, SIGNAL(clicked()), this, SLOT(on_findUp()));
addWidget(b);
b = new QToolButton(this);
b->setText("Down");
connect(b, SIGNAL(clicked()), this, SLOT(on_findDown()));
addWidget(b);
b = new QToolButton(this);
b->setIcon(QIcon(":/images/cog_alt_16x16.png"));
b->setMenu(p->menuGetMenuById(MENU_FIND_OPTIONS));
b->setPopupMode(QToolButton::InstantPopup);
addWidget(b);
b = new QToolButton(this);
b->setIcon(QIcon(":/images/x_14x14.png"));
connect(b, SIGNAL(clicked()), this, SLOT(on_findClose()));
addWidget(b);
setIconSize(QSize(16, 16));
setMovable(false);
setAutoFillBackground(true);
adjustSize();
searchedText->setFocus();
}
示例9: initToolbars
void BibleTime::initToolbars() {
QToolButton *openWorkButton = new QToolButton(this);
openWorkButton->setDefaultAction(m_openWorkAction);
openWorkButton->setPopupMode(QToolButton::InstantPopup);
m_mainToolBar->addWidget(openWorkButton);
m_mainToolBar->addAction(m_windowFullscreenAction);
QAction *a = m_actionCollection->action("showBookshelf");
Q_ASSERT(a != 0);
m_mainToolBar->addAction(a);
a = m_actionCollection->action("showBookmarks");
Q_ASSERT(a != 0);
m_mainToolBar->addAction(a);
a = m_actionCollection->action("showMag");
Q_ASSERT(a != 0);
m_mainToolBar->addAction(a);
m_mainToolBar->addAction(m_searchOpenWorksAction);
m_mainToolBar->addAction(m_openHandbookAction);
}
示例10: updateModulesenus
void MainWindow::updateModulesenus(QList<QMenu *> list)
{
if (list.count() > 0)
{
for (int i = 0; i < list.count(); ++i)
{
QMenu *menu = list.at(i);
if (menu != 0)
{
QToolButton* btn = new QToolButton(this);
btn->setText(menu->title());
btn->setPopupMode(QToolButton::InstantPopup);
btn->setToolTip(menu->title());
btn->setMenu(list.at(i));
_ui->toolBar->insertWidget(actOptions, btn);
}
}
_ui->toolBar->insertSeparator(actOptions);
}
}
示例11: QTabWidget
MainTab::MainTab(QWidget* parent) : QTabWidget(parent), m_lastIndex(0), m_lastIndexCur(0)
{
m_toolTabClose = new QToolButton(this);
m_toolTabClose->setIcon(QIcon(":/menu/tab_remove.png"));
m_toolTabClose->setEnabled(false);
setCornerWidget(m_toolTabClose);
connect(m_toolTabClose, SIGNAL(clicked()), this, SLOT(closeTabBtn()));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
QToolButton* btn = new QToolButton(this);
QMenu* tabOpenMenu = new QMenu(btn);
initAppTools(tabOpenMenu);
btn->setIcon(QIcon(":/menu/tab_new.png"));
btn->setPopupMode(QToolButton::InstantPopup);
btn->setMenu(tabOpenMenu);
setCornerWidget(btn, Qt::TopLeftCorner);
}
示例12: createWidgetForFlags
QWidget* PropertyEditor::createWidgetForFlags(const QString& name, const QVariant& value, QMetaEnum me, const QString &detail, QWidget* parent)
{
mProperties[name] = value;
QToolButton *btn = new QToolButton(parent);
if (!detail.isEmpty())
btn->setToolTip(detail);
btn->setObjectName(name);
btn->setText(QObject::tr(name.toUtf8().constData()));
btn->setPopupMode(QToolButton::InstantPopup);
ClickableMenu *menu = new ClickableMenu(btn);
menu->setObjectName(name);
btn->setMenu(menu);
for (int i = 0; i < me.keyCount(); ++i) {
QAction * a = menu->addAction(QString::fromLatin1(me.key(i)));
a->setCheckable(true);
a->setData(me.value(i));
a->setChecked(value.toInt() & me.value(i));
}
connect(menu, SIGNAL(triggered(QAction*)), SLOT(onFlagChange(QAction*)));
return btn;
}
示例13: setupMenus
void LiveWidget::setupMenus()
{
this->contextMenuLiveDropdown = new QMenu(this);
this->contextMenuLiveDropdown->setTitle("Dropdown");
this->audioTrackMenu = new QMenu(this);
this->audioTrackMenu->setTitle("Audio Track");
this->audioMenu = new QMenu(this);
this->audioMenu->setTitle("Audio");
this->audioTrackMenuAction = this->audioMenu->addMenu(this->audioTrackMenu);
this->audioMenu->addSeparator();
this->muteAction = this->audioMenu->addAction(/*QIcon(":/Graphics/Images/MuteSound.png"),*/ "Mute");
this->muteAction->setCheckable(true);
this->streamMenu = new QMenu(this);
this->streamMenu->setTitle("Connect to");
this->streamMenuAction = this->contextMenuLiveDropdown->addMenu(this->streamMenu);
this->contextMenuLiveDropdown->addSeparator();
this->contextMenuLiveDropdown->addMenu(this->audioMenu);
this->contextMenuLiveDropdown->addSeparator();
this->windowModeAction = this->contextMenuLiveDropdown->addAction(/*QIcon(":/Graphics/Images/WindowMode.png"),*/ "Window Mode", this, SLOT(toggleWindowMode()));
this->windowModeAction->setCheckable(true);
this->contextMenuLiveDropdown->addSeparator();
this->expandCollapseAction = this->contextMenuLiveDropdown->addAction(/*QIcon(":/Graphics/Images/Collapse.png"),*/ "Collapse", this, SLOT(toggleExpandCollapse()));
QObject::connect(this->streamMenuAction, SIGNAL(hovered()), this, SLOT(streamMenuHovered()));
QObject::connect(this->audioTrackMenuAction, SIGNAL(hovered()), this, SLOT(audioTrackMenuHovered()));
QObject::connect(this->streamMenu, SIGNAL(triggered(QAction*)), this, SLOT(streamMenuActionTriggered(QAction*)));
QObject::connect(this->audioTrackMenu, SIGNAL(triggered(QAction*)), this, SLOT(audioMenuActionTriggered(QAction*)));
QObject::connect(this->muteAction, SIGNAL(toggled(bool)), this, SLOT(muteAudio(bool)));
QToolButton* toolButtonLiveDropdown = new QToolButton(this);
toolButtonLiveDropdown->setObjectName("toolButtonLiveDropdown");
toolButtonLiveDropdown->setMenu(this->contextMenuLiveDropdown);
toolButtonLiveDropdown->setPopupMode(QToolButton::InstantPopup);
this->tabWidgetLive->setCornerWidget(toolButtonLiveDropdown);
//this->tabWidgetPreview->setTabIcon(0, QIcon(":/Graphics/Images/TabSplitter.png"));
}
示例14: QToolButton
QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
{
QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig();
QToolButton *toolButton = nullptr;
QWidget *container = nullptr;
if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
{
toolButton = new QToolButton();
toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
toolButton->setPopupMode( QToolButton::MenuButtonPopup );
container = toolButton;
}
else
{
container = new QWidget();
container->setLayout( new QHBoxLayout() );
container->layout()->setMargin( 0 );
}
QList< QAction * > actionList;
QAction *defaultAction = nullptr;
// first add user created layer actions
QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) );
Q_FOREACH ( const QgsAction &action, actions )
{
QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QLatin1String( "" );
QAction *act = new QAction( action.icon(), actionTitle, container );
act->setToolTip( action.name() );
act->setData( "user_action" );
act->setProperty( "fid", fid );
act->setProperty( "action_id", action.id() );
connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
actionList << act;
if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "AttributeTableRow" ) ).id() == action.id() )
defaultAction = act;
}
示例15: QMainWindow
MainWin::MainWin(CoreI *core, QWidget *parent)
: QMainWindow(parent), core_i(core), mousePressed(false),
closeToTray(false), hideFrame(false), toolWindow(false), roundCorners(false), onTop(false)
{
ui.setupUi(this);
icons_i = (IconsI *)core_i->get_interface(INAME_ICONS);
if(icons_i) setWindowIcon(icons_i->get_icon("generic"));
menus_i = (MenusI *)core_i->get_interface(INAME_MENUS);
QAction *exitAct;
if(menus_i) {
exitAct = menus_i->add_menu_action("Main Menu", tr("E&xit"), "quit");
sepAction = menus_i->add_menu_separator("Main Menu", exitAct);
winMenu = menus_i->get_menu("Main Menu");
} else {
winMenu = new QMenu("Main Menu", this);
sepAction = winMenu->addSeparator();
exitAct = new QAction(QApplication::style()->standardIcon(QStyle::SP_TitleBarCloseButton), tr("E&xit"), this);
winMenu->addAction(exitAct);
}
exitAct->setShortcut(tr("Ctrl+Q"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(quit()));
QToolButton *mainMenuButton = new QToolButton(this);
mainMenuButton->setMenu(winMenu);
mainMenuButton->setIcon(winMenu->icon());
mainMenuButton->setPopupMode(QToolButton::InstantPopup);
ui.toolBar->addWidget(mainMenuButton);
ui.toolBar->addAction(exitAct);
systray = new QSystemTrayIcon(this);
if(icons_i) systray->setIcon(icons_i->get_icon("generic"));
connect(systray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason)));
systray->setToolTip("saje");
systray->setContextMenu(winMenu);
systray->show();
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(ensureOnScreen(int)));
}