当前位置: 首页>>代码示例>>C++>>正文


C++ QToolButton::addAction方法代码示例

本文整理汇总了C++中QToolButton::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolButton::addAction方法的具体用法?C++ QToolButton::addAction怎么用?C++ QToolButton::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QToolButton的用法示例。


在下文中一共展示了QToolButton::addAction方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow), m_plugins(PluginRegistry::instance())
{
    ui->setupUi(this);

    connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(openEdit()));
    connect(ui->actionRecord, SIGNAL(triggered(bool)), this, SLOT(openRecord()));
    connect(ui->actionPlugins, SIGNAL(triggered(bool)), this, SLOT(openPlugins()));

    connect(ui->recordPage, SIGNAL(recordFinished()), this, SLOT(editRequests()));

    QToolButton *openButton = static_cast<QToolButton *>(ui->toolBar->widgetForAction(ui->actionOpen));
    openButton->setPopupMode(QToolButton::MenuButtonPopup);
    QAction *openSeparator = new QAction(this);
    openSeparator->setSeparator(true);
    openButton->addAction(openSeparator);

    QToolButton *saveButton = static_cast<QToolButton *>(ui->toolBar->widgetForAction(ui->actionSave));
    saveButton->setPopupMode(QToolButton::MenuButtonPopup);
    saveButton->addAction(ui->actionSaveAs);

    connect(ui->actionNew,    SIGNAL(triggered(bool)), ui->editPage, SLOT(newProject()));
    connect(ui->actionOpen,   SIGNAL(triggered(bool)), this,         SLOT(loadProject()));
    connect(ui->actionSave,   SIGNAL(triggered(bool)), this,         SLOT(saveProject()));
    connect(ui->actionSaveAs, SIGNAL(triggered(bool)), this,         SLOT(saveProjectAs()));

    selectAction(ui->actionEdit);

    updateOpenMenu();

    connect(&m_plugins, SIGNAL(toolPluginLoaded(QObject *)),
            ui->editPage, SLOT(addToolToToolbar(QObject *)));

    PostMonster::APIFunctions api;
    api.evalScript          = WorkEngine::evalScript;
    api.serializeRequest    = Common::serializeRequest;
    api.deserializeRequest  = Common::deserializeRequest;
    api.serializeResponse   = Common::serializeResponse;
    api.deserializeResponse = Common::deserializeResponse;
    api.defaultEncodings    = Common::encodings;
    api.dpiScaleFactor         = Common::dpiScaleFactor;
    m_plugins.loadPlugins(api);

    if (m_plugins.tool("http")) {
        PostMonster::HttpToolPluginInterface *httpTool =
                static_cast<PostMonster::HttpToolPluginInterface *>(m_plugins.tool("http"));

        ui->editPage->setRequestsModel(httpTool, &m_requestsModel);
        ui->recordPage->setRequestsModel(httpTool, &m_requestsModel);
    }

    connect(ui->editPage, &EditForm::debugStatusChanged, ui->actionNew, &QAction::setDisabled);
    connect(ui->editPage, &EditForm::debugStatusChanged, ui->actionOpen, &QAction::setDisabled);
    connect(ui->editPage, &EditForm::debugStatusChanged, ui->actionRecord, &QAction::setDisabled);

    foreach (QToolBar *toolBar, findChildren<QToolBar *>()) {
        toolBar->setIconSize(toolBar->iconSize() * Common::dpiScaleFactor());
    }
开发者ID:PostMonster,项目名称:postmonster,代码行数:59,代码来源:mainwindow.cpp

示例2: prepareSearchLine

 void prepareSearchLine()
 {
     ui->searchLine->setDelayedSignals(true);
     QToolButton *left = new QToolButton(q);
     left->setIcon(theme()->icon(Core::Constants::ICONSEARCH));
     ui->searchLine->setLeftButton(left);
     QToolButton *right = new QToolButton(q);
     right->addAction(aSearchMolsAndClass);
     right->addAction(aSearchClassOnly);
     right->addAction(aSearchMolsOnly);
     right->setDefaultAction(aSearchMolsAndClass);
     ui->searchLine->setRightButton(right);
     QObject::connect(right, SIGNAL(triggered(QAction*)), q, SLOT(toggleClassMolsFilter(QAction*)));
 }
开发者ID:Dinesh-Ramakrishnan,项目名称:freemedforms,代码行数:14,代码来源:interactoreditorwidget.cpp

示例3: 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();
      }
开发者ID:kcuzner,项目名称:MuseScore,代码行数:50,代码来源:edittools.cpp

示例4: 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 );

}
开发者ID:Ariki,项目名称:QGIS,代码行数:33,代码来源:qgsguivectorlayertools.cpp

示例5: 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);
    }
}
开发者ID:walterqin,项目名称:weighbridge,代码行数:34,代码来源:mainwindow.cpp

示例6: 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;
}
开发者ID:PeterTFS,项目名称:QGIS,代码行数:57,代码来源:qgsattributetableview.cpp

示例7: QToolButton

QWidget * SeekingButton::createWidget( QWidget * parent ) {
	QToolButton * button = new QToolButton(parent);
	button->setPopupMode(QToolButton::MenuButtonPopup);

	if (_actions.count() > 0 ) {
		button->setDefaultAction( _actions[0] );
	}
	for (int n = 1; n < _actions.count(); n++) {
		button->addAction( _actions[n] );
	}

	return button;
}
开发者ID:jinjianxin,项目名称:qt-opensource,代码行数:13,代码来源:widgetactions.cpp

示例8: createToolBar

void SCgWindow::createToolBar()
{
    mToolBar = new QToolBar(this);

    mToolBar->setIconSize(QSize(32, 32));

    QActionGroup* group = new QActionGroup(mToolBar);

    // Select mode
    QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar);
    action->setCheckable(true);
    action->setChecked(true);
    action->setShortcut(QKeySequence(tr("1", "Selection mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Select] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode()));

    //Pair creation mode
    action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("2", "Pair creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Pair] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onPairMode()));

    //Bus creation mode
    action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("3", "Bus creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Bus] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onBusMode()));

    //Contour creation mode
    action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("4", "Contour creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Contour] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onContourMode()));
    //
    mToolBar->addSeparator();
    //

    // align group button
    QToolButton *alignButton = new QToolButton(mToolBar);
    alignButton->setIcon(findIcon("tool-align.png"));
    alignButton->setPopupMode(QToolButton::InstantPopup);
    alignButton->setToolTip(tr("Alignment"));
    mToolBar->addWidget(alignButton);

    //Grid alignment
    action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("5", "Grid alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment()));

    // tuple alignment
    action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("6", "Tuple alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment()));

    //Vertical alignment
    action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("7", "Vertical alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment()));

    //Horizontal alignment
    action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("8", "Horizontal alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment()));

    // selection group button
    QToolButton *selectButton = new QToolButton(mToolBar);
    selectButton->setIcon(findIcon("tool-select-group.png"));
    selectButton->setPopupMode(QToolButton::InstantPopup);
    selectButton->setToolTip(tr("Selection group"));
    mToolBar->addWidget(selectButton);

    // input/output selection
    action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput()));

    // sbgraph selection
    action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
//.........这里部分代码省略.........
开发者ID:proper4ik,项目名称:kbe,代码行数:101,代码来源:scgwindow.cpp

示例9: createToolBar

void SCgWindow::createToolBar()
{
    mToolBar = new QToolBar(this);

    mToolBar->setIconSize(QSize(32, 32));

    QActionGroup* group = new QActionGroup(mToolBar);

    // Select mode
    QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar);
    action->setCheckable(true);
    action->setChecked(true);
    action->setShortcut(QKeySequence(tr("1", "Selection mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Select] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode()));

    //Pair creation mode
    action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("2", "Pair creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Pair] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onPairMode()));

    //Bus creation mode
    action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("3", "Bus creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Bus] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onBusMode()));

    //Contour creation mode
    action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar);
    action->setCheckable(true);
    action->setShortcut(QKeySequence(tr("4", "Contour creation mode")));
    group->addAction(action);
    mToolBar->addAction(action);
    mMode2Action[SCgScene::Mode_Contour] = action;
    connect(action, SIGNAL(triggered()), this, SLOT(onContourMode()));
    //
    mToolBar->addSeparator();
    //

    // align group button
    QToolButton *alignButton = new QToolButton(mToolBar);
    alignButton->setIcon(findIcon("tool-align.png"));
    alignButton->setPopupMode(QToolButton::InstantPopup);
    mToolBar->addWidget(alignButton);

    //Grid alignment
    action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("5", "Grid alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment()));

    // tuple alignment
    action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("6", "Tuple alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment()));

    //Vertical alignment
    action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("7", "Vertical alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment()));

    //Horizontal alignment
    action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("8", "Horizontal alignment")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment()));

    // Energy-based layout
    action = new QAction(findIcon("tool-align-energy.png"), tr("Energy-based layout"), mToolBar);
    action->setCheckable(false);
    action->setShortcut(QKeySequence(tr("9", "Energy-based layout")));
    alignButton->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onEnergyBasedLayout()));


    // selection group button
    QToolButton *selectButton = new QToolButton(mToolBar);
    selectButton->setIcon(findIcon("tool-select-group.png"));
    selectButton->setPopupMode(QToolButton::InstantPopup);
    mToolBar->addWidget(selectButton);

    // input/output selection
    action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar);
    action->setCheckable(false);
    selectButton->addAction(action);
//.........这里部分代码省略.........
开发者ID:pkkazantsev,项目名称:kbe,代码行数:101,代码来源:scgwindow.cpp

示例10: zoomRx

QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFlags flags )
  : QMainWindow( parent, flags )
  , mInterface( new QgsAppLayoutDesignerInterface( this ) )
  , mToolsActionGroup( new QActionGroup( this ) )
{
  if ( !sInitializedRegistry )
  {
    initializeRegistry();
  }
  QgsSettings settings;
  int size = settings.value( QStringLiteral( "IconSize" ), QGIS_ICON_SIZE ).toInt();
  setIconSize( QSize( size, size ) );
  setStyleSheet( QgisApp::instance()->styleSheet() );

  setupUi( this );
  setWindowTitle( tr( "QGIS Layout Designer" ) );

  setAttribute( Qt::WA_DeleteOnClose );
#if QT_VERSION >= 0x050600
  setDockOptions( dockOptions() | QMainWindow::GroupedDragging );
#endif

  //create layout view
  QGridLayout *viewLayout = new QGridLayout();
  viewLayout->setSpacing( 0 );
  viewLayout->setMargin( 0 );
  viewLayout->setContentsMargins( 0, 0, 0, 0 );
  centralWidget()->layout()->setSpacing( 0 );
  centralWidget()->layout()->setMargin( 0 );
  centralWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );

  mHorizontalRuler = new QgsLayoutRuler( nullptr, Qt::Horizontal );
  mVerticalRuler = new QgsLayoutRuler( nullptr, Qt::Vertical );
  mRulerLayoutFix = new QWidget();
  mRulerLayoutFix->setAttribute( Qt::WA_NoMousePropagation );
  mRulerLayoutFix->setBackgroundRole( QPalette::Window );
  mRulerLayoutFix->setFixedSize( mVerticalRuler->rulerSize(), mHorizontalRuler->rulerSize() );
  viewLayout->addWidget( mRulerLayoutFix, 0, 0 );
  viewLayout->addWidget( mHorizontalRuler, 0, 1 );
  viewLayout->addWidget( mVerticalRuler, 1, 0 );

  //initial state of rulers
  bool showRulers = settings.value( QStringLiteral( "LayoutDesigner/showRulers" ), true ).toBool();
  mActionShowRulers->setChecked( showRulers );
  mHorizontalRuler->setVisible( showRulers );
  mVerticalRuler->setVisible( showRulers );
  mRulerLayoutFix->setVisible( showRulers );
  mActionShowRulers->blockSignals( false );
  connect( mActionShowRulers, &QAction::triggered, this, &QgsLayoutDesignerDialog::showRulers );

  QMenu *rulerMenu = new QMenu( this );
  rulerMenu->addAction( mActionShowGuides );
  rulerMenu->addAction( mActionSnapGuides );
  rulerMenu->addAction( mActionManageGuides );
  rulerMenu->addAction( mActionClearGuides );
  rulerMenu->addSeparator();
  rulerMenu->addAction( mActionShowRulers );
  mHorizontalRuler->setContextMenu( rulerMenu );
  mVerticalRuler->setContextMenu( rulerMenu );

  connect( mActionRefreshView, &QAction::triggered, this, &QgsLayoutDesignerDialog::refreshLayout );

  connect( mActionShowGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::showGrid );
  connect( mActionSnapGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToGrid );

  connect( mActionShowGuides, &QAction::triggered, this, &QgsLayoutDesignerDialog::showGuides );
  connect( mActionSnapGuides, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToGuides );
  connect( mActionSmartGuides, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToItems );

  connect( mActionShowBoxes, &QAction::triggered, this, &QgsLayoutDesignerDialog::showBoxes );
  connect( mActionShowPage, &QAction::triggered, this, &QgsLayoutDesignerDialog::showPages );

  mView = new QgsLayoutView();
  //mView->setMapCanvas( mQgis->mapCanvas() );
  mView->setContentsMargins( 0, 0, 0, 0 );
  mView->setHorizontalRuler( mHorizontalRuler );
  mView->setVerticalRuler( mVerticalRuler );
  viewLayout->addWidget( mView, 1, 1 );
  //view does not accept focus via tab
  mView->setFocusPolicy( Qt::ClickFocus );
  mViewFrame->setLayout( viewLayout );
  mViewFrame->setContentsMargins( 0, 0, 0, 1 ); // 1 is deliberate!
  mView->setFrameShape( QFrame::NoFrame );

  connect( mActionClose, &QAction::triggered, this, &QWidget::close );

  // populate with initial items...
  const QList< int > itemMetadataIds = QgsGui::layoutItemGuiRegistry()->itemMetadataIds();
  for ( int id : itemMetadataIds )
  {
    itemTypeAdded( id );
  }
  //..and listen out for new item types
  connect( QgsGui::layoutItemGuiRegistry(), &QgsLayoutItemGuiRegistry::typeAdded, this, &QgsLayoutDesignerDialog::itemTypeAdded );

  QToolButton *orderingToolButton = new QToolButton( this );
  orderingToolButton->setPopupMode( QToolButton::InstantPopup );
  orderingToolButton->setAutoRaise( true );
  orderingToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly );
  orderingToolButton->addAction( mActionRaiseItems );
//.........这里部分代码省略.........
开发者ID:enzogis,项目名称:QGIS,代码行数:101,代码来源:qgslayoutdesignerdialog.cpp


注:本文中的QToolButton::addAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。