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


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

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


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

示例1: ConfigPageBase

CaptureConfigPage::CaptureConfigPage(QWidget *parent) :
    ConfigPageBase(parent)
{
    QFormLayout *formLayout = new QFormLayout();
    setLayout(formLayout);
    QHBoxLayout *hb = new QHBoxLayout();
    mpDir = new QLineEdit();
    hb->addWidget(mpDir);
    QToolButton *bt = new QToolButton();
    bt->setText("...");
    hb->addWidget(bt);
    connect(bt, SIGNAL(clicked()), SLOT(selectSaveDir()));
    bt = new QToolButton();
    bt->setText(tr("Browse"));
    hb->addWidget(bt);
    connect(bt, SIGNAL(clicked()), SLOT(browseCaptureDir()));
    formLayout->addRow(tr("Save dir"), hb);
    mpDir->setEnabled(false);
    mpDir->setText(Config::instance().captureDir());
    mpFormat = new QComboBox();
    formLayout->addRow(tr("Save format"), mpFormat);
    QList<QByteArray> formats;
    formats << "YUV" << QImageWriter::supportedImageFormats();
    foreach (QByteArray fmt, formats) {
        mpFormat->addItem(fmt);
    }
开发者ID:MichaelYaozy,项目名称:QtAV,代码行数:26,代码来源:CaptureConfigPage.cpp

示例2: QFileDialog

LyXFileDialog::LyXFileDialog(QString const & title,
			     QString const & path,
			     QStringList const & filters,
			     FileDialog::Button const & b1,
			     FileDialog::Button const & b2)
				 // FIXME replace that with guiApp->currentView()
	: QFileDialog(qApp->focusWidget(), title, path)
{
	setNameFilters(filters);
	setWindowTitle(title);
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
	setOption(QFileDialog::DontUseNativeDialog);

	QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();

	if (!b1.first.isEmpty()) {
		b1_dir_ = b1.second;
		QToolButton * tb = new QToolButton(this);
		connect(tb, SIGNAL(clicked()), this, SLOT(button1Clicked()));
		tb->setText(b1.first);
		layout.at(0)->addWidget(tb);
	}

	if (!b2.first.isEmpty()) {
		b2_dir_ = b2.second;
		QToolButton * tb = new QToolButton(this);
		connect(tb, SIGNAL(clicked()), this, SLOT(button2Clicked()));
		tb->setText(b2.first);
		layout.at(0)->addWidget(tb);
	}
}
开发者ID:cburschka,项目名称:lyx,代码行数:31,代码来源:LyXFileDialog.cpp

示例3: CreateStructureWidget

QWidget* CarManagePage::CreateStructureWidget()
{
	QGroupBox* structureWidget = new QGroupBox();

	QHBoxLayout* hBox = new QHBoxLayout();
	QToolButton* add = new QToolButton();
	add->setText("+");
	QToolButton* remove = new QToolButton();
	remove->setText( "-" );
	hBox->addWidget( add );
	hBox->addWidget( remove );
	hBox->addStretch( 1 );

	QTreeWidget* tree = new QTreeWidget();
	tree->setColumnCount( 1 );
	QTreeWidgetItem* root = new QTreeWidgetItem( QStringList( tr( "DaQing GPS Center") ) );
	QTreeWidgetItem* child1 = new QTreeWidgetItem( QStringList( tr( "test1" ) ) );
	QTreeWidgetItem* child2 = new QTreeWidgetItem( QStringList( tr( "test2" ) ) );
	root->addChild( child1 );
	root->addChild( child2 );
	root->setCheckState( 0, Qt::Unchecked );
	child1->setCheckState( 0, Qt::Unchecked );
	child2->setCheckState( 0, Qt::Unchecked );

	tree->addTopLevelItem( root );
	tree->expandAll();
	QVBoxLayout* vBox = new QVBoxLayout();
	vBox->addLayout( hBox );
	vBox->addWidget( tree );

	structureWidget->setLayout( vBox );
	return structureWidget;
}
开发者ID:zhygit,项目名称:QtTestGui,代码行数:33,代码来源:carmanagepage.cpp

示例4: reLabel

  /**
   * Creates and brings up the dialog box which allows the user to
   * re-label the plot various labes.
   * 
   */
  void ScatterPlotWindow::reLabel() {
    QDialog *dialog = new QDialog(p_scatterPlotWindow);
    dialog->setWindowTitle("Name Plot Labels");

    QWidget *buttons = new QWidget (dialog);
    QWidget *textAreas = new QWidget (dialog);
    QWidget *labels = new QWidget (dialog);
    QWidget *main = new QWidget (dialog);

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(main,0);
    layout->addWidget(buttons,0);
    dialog->setLayout(layout);

    QToolButton *okButton = new QToolButton(dialog);
    connect(okButton,SIGNAL(released()),this,SLOT(setLabels()));
    connect(okButton,SIGNAL(released()),dialog,SLOT(hide()));
    okButton->setShortcut(Qt::Key_Enter);
    okButton->setText("Ok");

    QToolButton *cancelButton = new QToolButton(dialog);
    connect(cancelButton,SIGNAL(released()),dialog,SLOT(hide()));
    cancelButton->setText("Cancel");

    QLabel *plotLabel = new QLabel("Plot Title: ");
    QLabel *xAxisLabel = new QLabel("X-Axis Label: ");
    QLabel *yAxisLabel = new QLabel("Y-Axis Label: ");

    QVBoxLayout *vlayout = new QVBoxLayout();
    vlayout->addWidget(plotLabel);
    vlayout->addWidget(xAxisLabel);
    vlayout->addWidget(yAxisLabel);    
    labels->setLayout(vlayout);

    p_plotTitleText = new QLineEdit(p_plot->title().text(),dialog);
    p_xAxisText = new QLineEdit(p_plot->axisTitle(QwtPlot::xBottom).text(),dialog);
    p_yAxisText = new QLineEdit(p_plot->axisTitle(QwtPlot::yLeft).text(),dialog);

    QVBoxLayout *v2layout = new QVBoxLayout();
    v2layout->addWidget(p_plotTitleText);
    v2layout->addWidget(p_xAxisText);
    v2layout->addWidget(p_yAxisText);
    textAreas->setLayout(v2layout);

    QHBoxLayout *mainLayout = new QHBoxLayout();
    mainLayout->addWidget(labels);
    mainLayout->addWidget(textAreas);
    main->setLayout(mainLayout);

    QHBoxLayout *hlayout = new QHBoxLayout();
    hlayout->addWidget(okButton);
    hlayout->addWidget(cancelButton);
    buttons->setLayout(hlayout);

    dialog->setFixedSize(400,190);
    dialog->show();
  }
开发者ID:assutech,项目名称:isis3,代码行数:62,代码来源:ScatterPlotWindow.cpp

示例5: createToolBar

void Painter::createToolBar()
{
    QToolBar *toolBar = addToolBar("Tool");
    QLabel *label_1 = new QLabel(tr("style:"));

    styleComboBox = new QComboBox;  //复选框
    styleComboBox->addItem("SolidLine", Qt::SolidLine);
    styleComboBox->addItem("DashLine", Qt::DashLine);
    styleComboBox->addItem("DotLine", Qt::DotLine);
    styleComboBox->addItem("DashDotLine", Qt::DashDotLine);
    styleComboBox->addItem("DashDotDotLine", Qt::DashDotDotLine);

    toolBar->addWidget(label_1);  //添加到bar上
    toolBar->addWidget(styleComboBox);
    toolBar->addSeparator();  //添加分割线

    connect(styleComboBox, SIGNAL(activated(int)), this, SLOT(slotStyle()));  //将选项和设置风格联系起来

    QLabel *label_2 = new QLabel(tr("width")); //画笔宽度 --
    widthSpinBox = new QSpinBox;
    widthSpinBox->setRange(0, 10);  //范围
    toolBar->addWidget(label_2);
    toolBar->addWidget(widthSpinBox);
    toolBar->addSeparator();

    connect(widthSpinBox, SIGNAL(valueChanged(int)), widget, SLOT(setWidth(int)));  //将设置的值和画笔宽度联系起来

//    colorBtn = new QToolButton;     //颜色
//    QPixmap pixmap(20, 20);
//    pixmap.fill(Qt::black);
//    colorBtn->setIcon(QIcon(pixmap));
//    toolBar->addWidget(colorBtn);
//    toolBar->addSeparator();

//    connect(colorBtn, SIGNAL(clicked()), this, SLOT(slotColor()));

    QToolButton *clearBtn = new QToolButton;
    clearBtn->setText(tr("clear"));
    toolBar->addWidget(clearBtn);
    toolBar->addSeparator();

    connect(clearBtn, SIGNAL(clicked()), widget, SLOT(clear()));

    QToolButton *prevBtn = new QToolButton;
    prevBtn->setText(tr("prev"));
    toolBar->addWidget(prevBtn);
    toolBar->addSeparator();

    connect(prevBtn, SIGNAL(clicked()), widget, SLOT(prev()));

    QToolButton *nextBtn = new QToolButton;
    nextBtn->setText(tr("next"));
    toolBar->addWidget(nextBtn);

    connect(nextBtn, SIGNAL(clicked()), widget, SLOT(next()));
}
开发者ID:RSroad,项目名称:xy_handwriting,代码行数:56,代码来源:painter.cpp

示例6: QDockWidget

QgsBrowserDockWidget::QgsBrowserDockWidget( QWidget * parent ) :
    QDockWidget( parent ), mModel( NULL )
{
  setWindowTitle( tr( "Browser" ) );

  mBrowserView = new QgsBrowserTreeView( this );

  QToolButton* refreshButton = new QToolButton( this );
  refreshButton->setIcon( QgsApplication::getThemeIcon( "mActionDraw.png" ) );
  // remove this to save space
  refreshButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
  refreshButton->setText( tr( "Refresh" ) );
  refreshButton->setToolTip( tr( "Refresh" ) );
  refreshButton->setAutoRaise( true );
  connect( refreshButton, SIGNAL( clicked() ), this, SLOT( refresh() ) );

  QToolButton* addLayersButton = new QToolButton( this );
  addLayersButton->setIcon( QgsApplication::getThemeIcon( "mActionAddLayer.png" ) );
  // remove this to save space
  addLayersButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
  addLayersButton->setText( tr( "Add Selection" ) );
  addLayersButton->setToolTip( tr( "Add Selected Layers" ) );
  addLayersButton->setAutoRaise( true );
  connect( addLayersButton, SIGNAL( clicked() ), this, SLOT( addSelectedLayers() ) );

  QToolButton* collapseButton = new QToolButton( this );
  collapseButton->setIcon( QgsApplication::getThemeIcon( "mActionCollapseTree.png" ) );
  collapseButton->setToolTip( tr( "Collapse All" ) );
  collapseButton->setAutoRaise( true );
  connect( collapseButton, SIGNAL( clicked() ), mBrowserView, SLOT( collapseAll() ) );

  QVBoxLayout* layout = new QVBoxLayout();
  QHBoxLayout* hlayout = new QHBoxLayout();
  layout->setContentsMargins( 0, 0, 0, 0 );
  layout->setSpacing( 0 );
  hlayout->setContentsMargins( 0, 0, 0, 0 );
  hlayout->setSpacing( 5 );
  hlayout->setAlignment( Qt::AlignLeft );

  hlayout->addSpacing( 5 );
  hlayout->addWidget( refreshButton );
  hlayout->addSpacing( 5 );
  hlayout->addWidget( addLayersButton );
  hlayout->addStretch( );
  hlayout->addWidget( collapseButton );
  layout->addLayout( hlayout );
  layout->addWidget( mBrowserView );

  QWidget* innerWidget = new QWidget( this );
  innerWidget->setLayout( layout );
  setWidget( innerWidget );

  connect( mBrowserView, SIGNAL( customContextMenuRequested( const QPoint & ) ), this, SLOT( showContextMenu( const QPoint & ) ) );
  connect( mBrowserView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( addLayerAtIndex( const QModelIndex& ) ) );

}
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:56,代码来源:qgsbrowserdockwidget.cpp

示例7: retranslateUi

 void retranslateUi(QDialog *MVPPlayerRemoteDialog)
 {
     MVPPlayerRemoteDialog->setWindowTitle(QApplication::translate("MVPPlayerRemoteDialog", "MVPPlayer - Remote", 0));
     lblVol->setText(QString());
     btnServer->setText(QApplication::translate("MVPPlayerRemoteDialog", "C", 0));
     cbMute->setText(QApplication::translate("MVPPlayerRemoteDialog", "Mute", 0));
     label->setText(QApplication::translate("MVPPlayerRemoteDialog", "Current track:", 0));
     lblCurrentTrack->setText(QString());
     lblTrackLength->setText(QString());
     btnClearPlaylist->setText(QApplication::translate("MVPPlayerRemoteDialog", "x", 0));
     lblPlaylist->setText(QApplication::translate("MVPPlayerRemoteDialog", "Playlist:", 0));
 } // retranslateUi
开发者ID:edubois,项目名称:mvp-player,代码行数:12,代码来源:ui_MVPPlayerRemoteDialog.hpp

示例8: createUI

void SensorWidget::createUI()
{
    if(m_pSensorModel)
    {
        // Sensor Selection
        QButtonGroup *qBGSensorSelection = new QButtonGroup;
        qBGSensorSelection->setExclusive(true);

        QVBoxLayout *VBoxSensorSelection = new QVBoxLayout;
        for(qint32 i = 0; i < m_pSensorModel->getSensorGroups().size(); ++i)
        {
            QToolButton *sensorSelectionButton = new QToolButton;
            sensorSelectionButton->setText(m_pSensorModel->getSensorGroups()[i].getGroupName());
            qBGSensorSelection->addButton(sensorSelectionButton,i);
            VBoxSensorSelection->addWidget(sensorSelectionButton);
        }

        connect(qBGSensorSelection, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), m_pSensorModel, &SensorModel::applySensorGroup);


        // Layout Selection
        QButtonGroup *qBGLayout = new QButtonGroup;
        qBGLayout->setExclusive(true);

        QHBoxLayout *HBoxButtonGroupLayout = new QHBoxLayout;

        for(qint32 i = 0; i < m_pSensorModel->getNumLayouts(); ++i)
        {
            QToolButton *buttonLayout = new QToolButton;
            buttonLayout->setText(m_pSensorModel->getSensorLayouts()[i].getName());
            buttonLayout->setCheckable(true);

            if(i == 0)
                buttonLayout->setChecked(true);
            else
                buttonLayout->setChecked(false);

            qBGLayout->addButton(buttonLayout, i);

            HBoxButtonGroupLayout->addWidget(buttonLayout);
        }

        connect(qBGLayout, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), m_pSensorModel, &SensorModel::setCurrentLayout);


        QGridLayout *topLayout = new QGridLayout;
        topLayout->addWidget(m_pGraphicsView, 0, 0);
        topLayout->addLayout(VBoxSensorSelection, 0, 1);
        topLayout->addLayout(HBoxButtonGroupLayout, 1, 0);

        setLayout(topLayout);
    }
}
开发者ID:slew,项目名称:mne-cpp,代码行数:53,代码来源:sensorwidget.cpp

示例9: QFrame

ListLayoutRow::ListLayoutRow(QWidget *widget, QWidget *parent, const bool &moveEnabled)
    : QFrame(parent)
{

    m_widget = widget;
    m_upButton = m_downButton = 0;

    setMidLineWidth(0);
    setLineWidth(1);
    setFrameStyle(QFrame::Box);
    setFrameShadow(QFrame::Sunken);    

    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

    QToolButton *removeButton = new QToolButton(this);
    removeButton->setIcon(KIcon("list-remove"));
    removeButton->setText(i18n("Remove"));
    removeButton->setToolTip(i18n("Remove"));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(removeClicked()));

    KSeparator *separator = new KSeparator(Qt::Vertical);
    
    QHBoxLayout *layout = new QHBoxLayout;
    
    if (moveEnabled) {
        QToolButton *upButton = new QToolButton(this);
        upButton->setIcon(KIcon("go-up"));
        upButton->setText(i18n("Move up"));
        upButton->setToolTip(i18n("Move up"));
    
        QToolButton *downButton = new QToolButton(this);
        downButton->setIcon(KIcon("go-down"));
        downButton->setText(i18n("Move down"));
        downButton->setToolTip(i18n("Move down"));
    
        connect(upButton, SIGNAL(clicked()), this, SLOT(upClicked()));
        connect(downButton, SIGNAL(clicked()), this, SLOT(downClicked()));
        
        layout->addWidget(upButton);
        layout->addWidget(downButton);
    
        m_upButton = upButton;
        m_downButton = downButton;
    }
    
    layout->addWidget(removeButton);
    layout->addWidget(separator);
    layout->addWidget(m_widget);
    setLayout(layout);
    
}
开发者ID:hippich,项目名称:recorditnow,代码行数:51,代码来源:listlayoutrow.cpp

示例10: QWidget

VESPERSBeamSelectorView::VESPERSBeamSelectorView(QWidget *parent)
	: QWidget(parent)
{
	currentBeam_ = 0;

	beams_ = new QButtonGroup;

	QToolButton *temp = new QToolButton;
	temp->setText("Pink");
	temp->setFixedSize(35, 22);
	temp->setCheckable(true);
	beams_->addButton(temp, 0);

	temp = new QToolButton;
	temp->setText("10%");
	temp->setFixedSize(35, 22);
	temp->setCheckable(true);
	beams_->addButton(temp, 1);

	temp = new QToolButton;
	temp->setText("1.6%");
	temp->setFixedSize(35, 22);
	temp->setCheckable(true);
	beams_->addButton(temp, 2);

	temp = new QToolButton;
	temp->setText("Si");
	temp->setFixedSize(35, 22);
	temp->setCheckable(true);
	beams_->addButton(temp, 3);

	connect(beams_, SIGNAL(buttonClicked(int)), this, SLOT(changeBeam(int)));
	connect(VESPERSBeamline::vespers(), SIGNAL(currentBeamChanged(VESPERS::Beam)), this, SLOT(onCurrentBeamChanged(VESPERS::Beam)));

	progressBar_ = new QProgressBar;
	progressBar_->hide();
	progressBar_->setRange(0, 100);

	QHBoxLayout *buttonsLayout = new QHBoxLayout;
	buttonsLayout->addWidget(beams_->button(0));
	buttonsLayout->addWidget(beams_->button(1));
	buttonsLayout->addWidget(beams_->button(2));
	buttonsLayout->addWidget(beams_->button(3));

	QVBoxLayout *beamSelectorLayout = new QVBoxLayout;
	beamSelectorLayout->addLayout(buttonsLayout);
	beamSelectorLayout->addWidget(progressBar_);

	setLayout(beamSelectorLayout);
}
开发者ID:acquaman,项目名称:acquaman,代码行数:50,代码来源:VESPERSBeamSelectorView.cpp

示例11: QMainWindow

Plot3D::Plot3D(QWidget *parent, Data *dat) : QMainWindow(parent)
{
    // pointers
    data = dat;

    // create 3D surface
    setData();

    // design widget
    QToolBar *toolBar = new QToolBar(this);

    QToolButton *btnSpectrogram = new QToolButton(toolBar);
    QToolButton *btnContour = new QToolButton(toolBar);
    QToolButton *btnPrint = new QToolButton(toolBar);

    btnPrint->setText("Print");
    btnPrint->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    toolBar->addWidget(btnPrint);

    addToolBar(toolBar);

    connect(btnPrint, SIGNAL(clicked()), this, SLOT(printPlot()));

    btnSpectrogram->setChecked(true);
    btnContour->setChecked(false);
}
开发者ID:piotrbetlej,项目名称:hexplorer,代码行数:26,代码来源:plot3d.cpp

示例12: createStatusBar

    void MainWindow::createStatusBar()
    {
        QColor windowColor = palette().window().color();
        QColor buttonBgColor = windowColor.lighter(105);
        QColor buttonBorderBgColor = windowColor.darker(120);
        QColor buttonPressedColor = windowColor.darker(102);

        QToolButton *log = new QToolButton(this);
        log->setText("Logs");
        log->setCheckable(true);
        log->setDefaultAction(_logDock->toggleViewAction());
        log->setStyleSheet(QString(
            "QToolButton {"
            "   background-color: %1;"
            "   border-style: outset;"
            "   border-width: 1px;"
            "   border-radius: 3px;"
            "   border-color: %2;"
            "   padding: 1px 20px 1px 20px;"
            "} \n"
            ""
            "QToolButton:checked, QToolButton:pressed {"
            "   background-color: %3;"
            "   border-style: inset;"
            "}")
            .arg(buttonBgColor.name())
            .arg(buttonBorderBgColor.name())
            .arg(buttonPressedColor.name()));

        statusBar()->insertWidget(0, log);
        statusBar()->setStyleSheet("QStatusBar::item { border: 0px solid black };");
    }
开发者ID:Dinesh-Ramakrishnan,项目名称:robomongo,代码行数:32,代码来源:MainWindow.cpp

示例13: QWidgetAction

HelpQuery::HelpQuery(QWidget* parent)
   : QWidgetAction(parent)
      {
      mapper = new QSignalMapper(this);

      w = new QWidget(parent);
      QHBoxLayout* layout = new QHBoxLayout;

      QLabel* label = new QLabel;
      label->setText(tr("Search for: "));
      layout->addWidget(label);

      entry = new QLineEdit;
      layout->addWidget(entry);

      QToolButton* button = new QToolButton;
      button->setText("x");
      layout->addWidget(button);

      w->setLayout(layout);
      setDefaultWidget(w);

      emptyState = true;

      connect(button, SIGNAL(clicked()), entry, SLOT(clear()));
      connect(entry, SIGNAL(textChanged(const QString&)), SLOT(textChanged(const QString&)));
      connect(entry, SIGNAL(returnPressed()), SLOT(returnPressed()));
      connect(mapper, SIGNAL(mapped(QObject*)), SLOT(actionTriggered(QObject*)));
      }
开发者ID:jpirie,项目名称:MuseScore,代码行数:29,代码来源:help.cpp

示例14: drawModeMenuPressed

void EFFEditorScenePanel::drawModeMenuPressed(QAction * action)
{
	QToolButton * drawMode = qobject_cast<QToolButton *>(action->parentWidget()->parentWidget());
	drawMode->setText(action->text());

	if ( action->text() == tr("Wireframe") )
	{
		static bool firstTime = true;

		static EFFNetClient * client = NULL;
		if ( firstTime )
		{
			client = new EFFNetClient();
			client->Init();
			client->Connect(_effT("tcp://localhost:5555"));
			firstTime = false;
		}

		EFFObjectManager * objectManager = EFFGetObjectManager(EFF3DObject::GetThisClass());

		EFF3DObject * gameObject = (EFF3DObject *)objectManager->GetObject(1);

		EFFComponent * component = gameObject->GetComponent(0);

		client->Send(gameObject, effString(_effT("Name")));



		//client->Shutdown();
	}
}
开发者ID:chena1982,项目名称:eff,代码行数:31,代码来源:EFFEditorScenePanel.cpp

示例15: parseROSParameters

  EmptyServiceCallInterfaceAction::EmptyServiceCallInterfaceAction( QWidget* parent )
    : rviz::Panel( parent )
  {
    parseROSParameters();

    QHBoxLayout* h_layout = new QHBoxLayout;
    h_layout->setAlignment(Qt::AlignLeft);
    layout = new QVBoxLayout();
    signal_mapper = new QSignalMapper(this);

    for(size_t i = 0; i < service_call_button_infos_.size();i++){
      ServiceCallButtonInfo target_button = service_call_button_infos_[i];
      QToolButton* tbutton = new QToolButton(this);
      tbutton->setText(target_button.text.c_str());
      tbutton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
      tbutton->setIconSize(QSize(100, 100));
      tbutton->setIcon(QIcon(QPixmap(QString(target_button.icon_file_path.c_str()))));
      connect(tbutton, SIGNAL(clicked()), signal_mapper, SLOT(map()));
      signal_mapper->setMapping(tbutton, i);
      h_layout->addWidget(tbutton);
    };
    connect(signal_mapper, SIGNAL(mapped(int)),
            this, SLOT(callRequestEmptyCommand(int)));
    layout->addLayout(h_layout);
    setLayout( layout );
  }
开发者ID:AtsushiSakai,项目名称:jsk_visualization,代码行数:26,代码来源:empty_service_call_interface.cpp


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