本文整理汇总了C++中QToolButton::setDefaultAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::setDefaultAction方法的具体用法?C++ QToolButton::setDefaultAction怎么用?C++ QToolButton::setDefaultAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolButton
的用法示例。
在下文中一共展示了QToolButton::setDefaultAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: createFiltersDock
void TabDeckEditor::createFiltersDock()
{
filterModel = new FilterTreeModel();
filterModel->setObjectName("filterModel");
databaseDisplayModel->setFilterTree(filterModel->filterTree());
databaseDisplayModel->setObjectName("databaseDisplayModel");
filterView = new QTreeView;
filterView->setObjectName("filterView");
filterView->setModel(filterModel);
filterView->setUniformRowHeights(true);
filterView->setHeaderHidden(true);
filterView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(filterModel, SIGNAL(layoutChanged()), filterView, SLOT(expandAll()));
connect(filterView, SIGNAL(customContextMenuRequested(const QPoint &)),this, SLOT(filterViewCustomContextMenu(const QPoint &)));
FilterBuilder *filterBuilder = new FilterBuilder;
filterBuilder->setObjectName("filterBuilder");
connect(filterBuilder, SIGNAL(add(const CardFilter *)), filterModel, SLOT(addFilter(const CardFilter *)));
QToolButton *filterDelOne = new QToolButton();
filterDelOne->setObjectName("filterDelOne");
filterDelOne->setDefaultAction(aClearFilterOne);
filterDelOne->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QToolButton *filterDelAll = new QToolButton();
filterDelAll->setObjectName("filterDelAll");
filterDelAll->setDefaultAction(aClearFilterAll);
filterDelAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QGridLayout *filterLayout = new QGridLayout;
filterLayout->setObjectName("filterLayout");
filterLayout->setContentsMargins(0,0,0,0);
filterLayout->addWidget(filterBuilder, 0, 0, 1, 3);
filterLayout->addWidget(filterView, 1, 0, 1, 3);
filterLayout->addWidget(filterDelOne, 2, 0, 1, 1);
filterLayout->addWidget(filterDelAll, 2, 2, 1, 1);
filterBox = new QWidget();
filterBox->setObjectName("filterBox");
filterBox->setLayout(filterLayout);
QVBoxLayout *filterFrame = new QVBoxLayout;
filterFrame->setObjectName("filterFrame");
filterFrame->addWidget(filterBox);
filterDock = new QDockWidget(MainWindow);
filterDock->setObjectName("filterDock");
filterDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
QWidget *filterDockContents = new QWidget(MainWindow);
filterDockContents->setObjectName("filterDockContents");
filterDockContents->setLayout(filterFrame);
filterDock->setWidget(filterDockContents);
connect(btnFilter,SIGNAL(toggled(bool)),filterDock,SLOT(setVisible(bool)));
filterDock->installEventFilter(this);
}
示例3: createActionWidget
QWidget* QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
{
QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig();
QgsActionManager* actions = mFilterModel->layer()->actions();
QToolButton* toolButton = nullptr;
QWidget* container = nullptr;
if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
{
toolButton = new QToolButton( this );
toolButton->setPopupMode( QToolButton::MenuButtonPopup );
container = toolButton;
}
else
{
container = new QWidget( this );
container->setLayout( new QHBoxLayout() );
container->layout()->setMargin( 0 );
}
for ( int i = 0; i < actions->size(); ++i )
{
const QgsAction& action = actions->at( i );
if ( !action.showInAttributeTable() )
continue;
QAction* act = new QAction( action.icon(), action.shortTitle().isEmpty() ? action.name() : action.shortTitle(), toolButton );
act->setToolTip( action.name() );
act->setData( i );
act->setProperty( "fid", fid );
connect( act, SIGNAL( triggered( bool ) ), this, SLOT( actionTriggered() ) );
if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
{
toolButton->addAction( act );
if ( actions->defaultAction() == i )
toolButton->setDefaultAction( act );
container = toolButton;
}
else
{
QToolButton* btn = new QToolButton;
btn->setDefaultAction( act );
container->layout()->addWidget( btn );
}
}
if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
toolButton->setDefaultAction( toolButton->actions().first() );
return container;
}
示例4: settings
NavFichiers::NavFichiers(QWidget *parent) : QMainWindow(parent)
{
QSettings settings(Multiuso::appDirPath() + "/ini/nav_fichiers.ini", QSettings::IniFormat);
if (settings.value("view_type").toString().isEmpty())
settings.setValue("view_type", "Tableau");
selectView = new QComboBox;
selectView->addItems(QStringList() << "Tableau" << "Liste");
selectView->setCurrentIndex(selectView->findText(settings.value("view_type").toString()));
connect(selectView, SIGNAL(currentIndexChanged(QString)), this, SLOT(viewChanged(QString)));
status = statusBar();
status->addPermanentWidget(new QLabel("Vue : "));
status->addPermanentWidget(selectView);
creerActions();
QToolButton *buttonNewTab = new QToolButton;
buttonNewTab->setDefaultAction(actionNouvelOnglet);
buttonNewTab->setAutoRaise(true);
QToolButton *buttonCloseTab = new QToolButton;
buttonCloseTab->setDefaultAction(actionFermerOnglet);
buttonCloseTab->setAutoRaise(true);
onglets = new QTabWidget;
onglets->setMovable(true);
onglets->setDocumentMode(true);
onglets->setCornerWidget(buttonNewTab, Qt::BottomLeftCorner);
onglets->setCornerWidget(buttonCloseTab, Qt::BottomRightCorner);
connect(onglets, SIGNAL(tabCloseRequested(int)), this, SLOT(slotFermerOnglet(int)));
connect(onglets, SIGNAL(currentChanged(int)), this, SLOT(slotOngletChange(int)));
ajouterOnglet();
onglets->setTabsClosable(false);
setCentralWidget(onglets);
QSettings reglages(Multiuso::appDirPath() + "/ini/nav_fichiers.ini", QSettings::IniFormat);
restoreState(reglages.value("etat_fenetre").toByteArray());
QShortcut *shortcutSwitchTab = new QShortcut(QKeySequence("Ctrl+Tab"), this);
connect(shortcutSwitchTab, SIGNAL(activated()), this, SLOT(slotSwitchTab()));
p_fenPrincipale = parent;
p_navigateurWeb = NULL;
m_copyCutObject = new CopyCutObject;
}
示例5: QDockWidget
EditTools::EditTools(QWidget* parent)
: QDockWidget(parent)
{
setObjectName("edit-tools");
setWindowTitle(tr("Edit Mode Tools"));
setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea));
QToolBar* tb = new QToolBar(tr("Edit Mode Tools"));
tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight));
QToolButton* b = new QToolButton(this);
QAction* a = getAction("hraster");
a->setCheckable(true);
b->setDefaultAction(a);
b->setContextMenuPolicy(Qt::ActionsContextMenu);
b->addAction(getAction("config-raster"));
tb->addWidget(b);
b = new QToolButton(this);
a = getAction("vraster");
a->setCheckable(true);
b->setDefaultAction(a);
b->setContextMenuPolicy(Qt::ActionsContextMenu);
b->addAction(getAction("config-raster"));
tb->addWidget(b);
_editX = new QDoubleSpinBox(this);
_editX->setSuffix(tr("sp"));
_editX->setRange(-99999, 99999);
_editX->setSingleStep(.1);
_editY = new QDoubleSpinBox(this);
_editY->setSuffix(tr("sp"));
_editY->setRange(-99999, 99999);
_editY->setSingleStep(.1);
xLabel = new QLabel(tr("x:"), this);
yLabel = new QLabel(tr("y:"), this);
_localEdit = false;
tb->addWidget(xLabel);
tb->addWidget(_editX);
tb->addWidget(yLabel);
tb->addWidget(_editY);
connect(_editX, SIGNAL(valueChanged(double)), SLOT(editXChanged(double)));
connect(_editY, SIGNAL(valueChanged(double)), SLOT(editYChanged(double)));
setWidget(tb);
QWidget* w = new QWidget(this);
setTitleBarWidget(w);
titleBarWidget()->hide();
}
示例6: createWidget
QWidget *KToolBarPopupAction::createWidget(QWidget *_parent)
{
QToolBar *parent = qobject_cast<QToolBar *>(_parent);
if (!parent) {
return QWidgetAction::createWidget(_parent);
}
QToolButton *button = new QToolButton(parent);
button->setAutoRaise(true);
button->setFocusPolicy(Qt::NoFocus);
button->setIconSize(parent->iconSize());
button->setToolButtonStyle(parent->toolButtonStyle());
button->setDefaultAction(this);
connect(parent, &QToolBar::iconSizeChanged,
button, &QAbstractButton::setIconSize);
connect(parent, &QToolBar::toolButtonStyleChanged,
button, &QToolButton::setToolButtonStyle);
connect(button, &QToolButton::triggered,
parent, &QToolBar::actionTriggered);
if (d->delayed)
if (d->stickyMenu) {
button->setPopupMode(QToolButton::MenuButtonPopup);
} else {
button->setPopupMode(QToolButton::DelayedPopup);
}
else {
button->setPopupMode(QToolButton::InstantPopup);
}
return button;
}
示例7: ValueEdit
RotationEdit::RotationEdit( QWidget * parent ) : ValueEdit( parent ), mode( mAuto ), setting( false )
{
actMode = new QAction( this );
connect( actMode, &QAction::triggered, this, &RotationEdit::switchMode );
QToolButton * btMode = new QToolButton( this );
btMode->setDefaultAction( actMode );
QHBoxLayout * lay = new QHBoxLayout( this );
lay->setMargin( 0 );
lay->setSpacing( 0 );
lay->addWidget( btMode, 2 );
// Cast QDoubleSpinBox slot
auto dsbValueChanged = static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged);
for ( int x = 0; x < 4; x++ ) {
lay->addWidget( l[x] = new CenterLabel, 1 );
lay->addWidget( v[x] = new QDoubleSpinBox, 5 );
connect( v[x], dsbValueChanged, this, &RotationEdit::sltChanged );
}
setFocusProxy( v[0] );
setupMode();
}
示例8: QMainWindow
/**
* @brief 构造函数
* @param [I] 平台指针
* @param [I] 父指针
* @param [I] 窗口标志
*/
MainWindow::MainWindow(Workbench *wb, QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
, ui(new Ui::MainWindowClass)
, m_workbench(wb)
{
ui->setupUi(this);
m_messageWidget = MessageWidget::instance();
m_messageWidget->setParent(this, Qt::Tool);
QStatusBar *statusBar = this->statusBar();
{
QToolButton *button = new QToolButton(statusBar);
button->setIcon(QApplication::style()->standardIcon(QStyle::SP_FileDialogDetailedView));
button->setAutoRaise(true);
connect(button, SIGNAL(clicked()), workbench(), SLOT(showDebugger()));
statusBar->addPermanentWidget(button);
}
// 显示消息按钮
{
QToolButton *button = new QToolButton(statusBar);
button->addAction(m_messageWidget->toggleAction());
button->setDefaultAction(m_messageWidget->toggleAction());
button->setAutoRaise(true);
statusBar->addPermanentWidget(button);
}
}
示例9: QDialog
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent)
{
setWindowTitle(tr("Configure %1").arg(KtikzApplication::applicationName()));
addPage(generalPage(), tr("&General"), "preferences-desktop-theme");
addPage(editorPage(), tr("&Editor"), "accessories-text-editor");
addPage(appearancePage(), tr("&Highlighting"), "preferences-desktop-color");
QDialogButtonBox *buttonBox = new QDialogButtonBox;
QAction *whatsThisAction = QWhatsThis::createAction(this);
whatsThisAction->setIcon(Icon("help-contextual"));
QToolButton *whatsThisButton = new QToolButton(this);
whatsThisButton->setDefaultAction(whatsThisAction);
whatsThisButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
buttonBox->addButton(whatsThisButton, QDialogButtonBox::HelpRole);
buttonBox->addButton(QDialogButtonBox::Ok);
buttonBox->addButton(QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(centerWidget());
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
}
示例10: populateButtonLayout
void PresetWidget::populateButtonLayout()
{
//delete old stuff
if(mButtonLayout)
{
QLayoutItem *child;
while ((child = mButtonLayout->takeAt(0)) != 0)
{
// delete both the layoutitem AND the widget. Not auto done because layoutitem is no QObject.
QWidget* widget = child->widget();
delete child;
delete widget;
}
delete mButtonLayout;
}
//make the new buttons
mButtonLayout = new QHBoxLayout;
mLayout->addLayout(mButtonLayout);
QList<QAction*> actions = mActionGroup->actions();
for (int i=0; i<actions.size(); ++i)
{
QToolButton* button = new QToolButton(this);
button->setDefaultAction(actions[i]);
button->show();
mButtonLayout->addWidget(button);
}
mButtonLayout->addStretch();
}
示例11: addActionWithoutButtonGroup
/*!
\fn OptToolBar::addActionWithoutButtonGroup(QAction* action)
*/
QToolButton* OptToolBar::addActionWithoutButtonGroup(QAction* action)
{
if(!action)
{
return NULL;
}
int id = mRow*mColSize + mCol;
//create new button
QToolButton *button = new QToolButton;
button->setToolTip( action->statusTip() );
button->setDefaultAction(action);
//set the button icon using action's icon
QIcon icon = action->icon();
if( !icon.isNull() )
{
button->setIcon(icon);
//button->setIconSize( QSize(50, 50) );
}
mButtons[ id ]= make_pair(button, action);
mLayout->addWidget(button, mRow, mCol);
//update row and col
if( mCol+1>=mColSize )
{
++mRow;
}
mCol = (mCol+1) % mColSize;
return button;
}
示例12: onCameraChangeAction
void QCastViewGL::onCameraChangeAction()
{
QAction *pAct = qobject_cast< QAction* >(QObject::sender());
if (!pAct) return;
QVariant v = pAct->data();
void* pc = v.value<void*>();
cogx::display::CDisplayCamera* pCamera = static_cast<cogx::display::CDisplayCamera*>(pc);
//std::cout << pAct << " " << pAct->text().toStdString() << " " << pc << " " << pCamera << std::endl;
if (pCamera) {
// TODO: should check if it is valid -- is it in getCameras()?
selectCamera(pCamera);
}
// Replace the action for the button.
// Parent hierarchy: action -> menu -> button
QMenu *pMenu = qobject_cast< QMenu* >(pAct->parent());
if (pMenu) {
QToolButton* pBut = qobject_cast< QToolButton* >(pMenu->parent());
if (pBut) {
QAction *pOldAct = pBut->defaultAction();
if (pOldAct && pOldAct->parent() == pAct->parent()) {
//std::cout << "Changing default action" << std::endl;
pBut->setDefaultAction(pAct);
}
}
}
}
示例13: GetUpdate
QToolButton* PackagesDelegate::GetUpdate (const QModelIndex& index) const
{
int row = index.row ();
if (!Row2Update_.contains (row))
{
QAction *action = new QAction (Core::Instance ()
.GetProxy ()->GetIcon ("update"),
tr ("Update"),
Viewport_);
action->setCheckable (true);
action->setProperty ("Role", "Update");
connect (action,
SIGNAL (triggered ()),
this,
SLOT (handleAction ()));
QToolButton *toolButton = new QToolButton ();
toolButton->resize (CActionsSize, CActionsSize);
toolButton->setDefaultAction (action);
Row2Update_ [row] = toolButton;
}
QToolButton *button = Row2Update_ [row];
QAction *action = button->defaultAction ();
bool upgradable = index.data (PackagesModel::PMRUpgradable).toBool ();
action->setEnabled (upgradable);
action->setData (index.data (PackagesModel::PMRPackageID));
WasUpgradable_ [index] = upgradable;
return button;
}
示例14: QIcon
DetailedLabeledComboBoxWidget::DetailedLabeledComboBoxWidget(QWidget* parent, StringPropertyBasePtr adapter, QGridLayout* gridLayout, int row) :
LabeledComboBoxWidget(parent, adapter, gridLayout, row)
{
//Add detailed button
QAction* detailsAction = this->createAction(this,
QIcon(":/icons/open_icon_library/system-run-5.png"),
"Details", "Toggle Details",
SLOT(toggleDetailsSlot()),
NULL);
QToolButton* detailsButton = new QToolButton();
detailsButton->setObjectName("DetailedButton");
detailsButton->setDefaultAction(detailsAction);
if (gridLayout) // add to input gridlayout
{
gridLayout->addWidget(detailsButton, row, 2);
}
else // add directly to this
{
mTopLayout->addWidget(detailsButton, 2);
}
this->setModified();
}
示例15: commitError
void QgsGuiVectorLayerTools::commitError( QgsVectorLayer* vlayer ) const
{
QgsMessageViewer *mv = new QgsMessageViewer();
mv->setWindowTitle( tr( "Commit errors" ) );
mv->setMessageAsPlainText( tr( "Could not commit changes to layer %1" ).arg( vlayer->name() )
+ "\n\n"
+ tr( "Errors: %1\n" ).arg( vlayer->commitErrors().join( "\n " ) )
);
QToolButton *showMore = new QToolButton();
// store pointer to vlayer in data of QAction
QAction *act = new QAction( showMore );
act->setData( QVariant( QMetaType::QObjectStar, &vlayer ) );
act->setText( tr( "Show more" ) );
showMore->setStyleSheet( "background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" );
showMore->setCursor( Qt::PointingHandCursor );
showMore->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
showMore->addAction( act );
showMore->setDefaultAction( act );
connect( showMore, SIGNAL( triggered( QAction* ) ), mv, SLOT( exec() ) );
connect( showMore, SIGNAL( triggered( QAction* ) ), showMore, SLOT( deleteLater() ) );
// no timeout set, since notice needs attention and is only shown first time layer is labeled
QgsMessageBarItem *errorMsg = new QgsMessageBarItem(
tr( "Commit errors" ),
tr( "Could not commit changes to layer %1" ).arg( vlayer->name() ),
showMore,
QgsMessageBar::WARNING,
0,
QgisApp::instance()->messageBar() );
QgisApp::instance()->messageBar()->pushItem( errorMsg );
}