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


C++ QSpinBox::setValue方法代码示例

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


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

示例1: createColorChooser

/* --------------------------------------------------------------------------
 * createColorChooser
 *
 * Creates a simple widget for choosing an RGB color value.
 * -------------------------------------------------------------------------- */
void ObjectPanel::createColorChooser()
{
    QLabel   *labelR   = new QLabel( tr( "Red" ) );
    QLabel   *labelG   = new QLabel( tr( "Green" ) );
    QLabel   *labelB   = new QLabel( tr( "Blue" ) );
    QSpinBox *spinBoxR = new QSpinBox;
    QSpinBox *spinBoxG = new QSpinBox;
    QSpinBox *spinBoxB = new QSpinBox;
    m_pSliderR         = new QSlider( Qt::Horizontal );
    m_pSliderG         = new QSlider( Qt::Horizontal );
    m_pSliderB         = new QSlider( Qt::Horizontal );


    labelR->setFixedWidth( 40 );
    labelG->setFixedWidth( 40 );
    labelB->setFixedWidth( 40 );
    spinBoxR->setRange( 0, 255 );
    spinBoxG->setRange( 0, 255 );
    spinBoxB->setRange( 0, 255 );
    m_pSliderR->setRange( 0, 255 );
    m_pSliderG->setRange( 0, 255 );
    m_pSliderB->setRange( 0, 255 );

    /* Connect status changes of spinboxes to corresponding
     * sliders and vice versa. */
    connect( spinBoxR, SIGNAL( valueChanged( int ) ),
             m_pSliderR, SLOT( setValue( int ) ) );
    connect( m_pSliderR, SIGNAL( valueChanged( int ) ),
             spinBoxR, SLOT( setValue( int ) ) );

    connect( spinBoxG, SIGNAL( valueChanged( int ) ),
             m_pSliderG, SLOT( setValue( int ) ) );
    connect( m_pSliderG, SIGNAL( valueChanged( int ) ),
             spinBoxG, SLOT( setValue( int ) ) );

    connect( spinBoxB, SIGNAL( valueChanged( int ) ),
             m_pSliderB, SLOT( setValue( int ) ) );
    connect( m_pSliderB, SIGNAL( valueChanged( int ) ),
             spinBoxB, SLOT( setValue( int ) ) );

    /* Connect the color change signal sent by Renderer. (to this) */
    connect( m_pRenderer, SIGNAL( objectRGB( int, int, int ) ),
             this, SLOT( setRGBValues( int, int, int ) ) );

    /* Connect the color change signal sent by this. (to the renderer) */
    connect( this, SIGNAL( colorChanged( int, int, int) ),
             m_pRenderer, SLOT( changeObjectColor( int, int, int ) ) );

    /* Call sendRGBValues() if any of the sliders change state. */
    connect( m_pSliderR, SIGNAL( valueChanged( int ) ),
             this, SLOT( sendRGBValues() ) );
    connect( m_pSliderG, SIGNAL( valueChanged( int ) ),
             this, SLOT( sendRGBValues() ) );
    connect( m_pSliderB, SIGNAL( valueChanged( int ) ),
             this, SLOT( sendRGBValues() ) );

    spinBoxR->setValue( 0 );
    spinBoxG->setValue( 0 );
    spinBoxB->setValue( 0 );

    /* Create layout for the widget. */
    QHBoxLayout *layoutR = new QHBoxLayout;
    QHBoxLayout *layoutG = new QHBoxLayout;
    QHBoxLayout *layoutB = new QHBoxLayout;
    layoutR->addWidget( labelR );
    layoutR->addWidget( m_pSliderR );
    layoutR->addWidget( spinBoxR );
    layoutG->addWidget( labelG );
    layoutG->addWidget( m_pSliderG );
    layoutG->addWidget( spinBoxG );
    layoutB->addWidget( labelB );
    layoutB->addWidget( m_pSliderB );
    layoutB->addWidget( spinBoxB );
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addLayout( layoutR );
    layout->addLayout( layoutG );
    layout->addLayout( layoutB );

    setLayout( layout );
}
开发者ID:kilppari,项目名称:turtleRenderer,代码行数:85,代码来源:mainwindow.cpp

示例2: setEditorData

void TruckBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
    int         value = index.model()->data(index, Qt::EditRole).toInt();

    QSpinBox    *spinBox = dynamic_cast<QSpinBox *>(editor);
    spinBox->setValue(value);
}
开发者ID:danylo-bilyk,项目名称:trucks,代码行数:6,代码来源:node.cpp

示例3: createWidget

    void AbstractFilter::createWidget()
    {
      QRadioButton * inclusiveButton = new QRadioButton("Inclusive");
      inclusiveButton->setFont(*smallFont);
      QRadioButton * exclusiveButton = new QRadioButton("Exclusive");
      exclusiveButton->setFont(*smallFont);

      inclusiveExclusiveGroup = new QButtonGroup;
      connect(inclusiveExclusiveGroup, SIGNAL(buttonClicked(int)),
          this, SIGNAL(filterChanged()));
      inclusiveExclusiveGroup->addButton(inclusiveButton, 0);
      inclusiveExclusiveGroup->addButton(exclusiveButton, 1);

      inclusiveExclusiveLayout = new QHBoxLayout;
      QMargins margins = inclusiveExclusiveLayout->contentsMargins();
      margins.setTop(0);
      margins.setBottom(0);
      inclusiveExclusiveLayout->setContentsMargins(margins);
      inclusiveExclusiveLayout->addWidget(inclusiveButton);
      inclusiveExclusiveLayout->addWidget(exclusiveButton);

      QHBoxLayout * controlsLayout = new QHBoxLayout;
      margins = controlsLayout->contentsMargins();
      margins.setTop(0);
      margins.setBottom(0);
      controlsLayout->setContentsMargins(margins);

      controlsLayout->addLayout(inclusiveExclusiveLayout);

      effectivenessGroup = new QButtonGroup();
      effectivenessGroup->setExclusive(false);

      if (effectivenessFlags->testFlag(Images))
        effectivenessGroup->addButton(
            createEffectivenessCheckBox("&Images"), 0);

      if (effectivenessFlags->testFlag(Points))
        effectivenessGroup->addButton(
            createEffectivenessCheckBox("&Points"), 1);

      if (effectivenessFlags->testFlag(Measures))
        effectivenessGroup->addButton(
            createEffectivenessCheckBox("&Measures"), 2);

      QString firstGroupEntry;
      ASSERT(effectivenessGroup->buttons().size());
      if (effectivenessGroup->buttons().size())
      {
        firstGroupEntry = effectivenessGroup->buttons()[0]->text();
        firstGroupEntry.remove(0, 1);
      }

      QList<QAbstractButton *> buttons = effectivenessGroup->buttons();
      if (effectivenessGroup->buttons().size() >= 2)
      {
        QHBoxLayout * effectivenessLayout = new QHBoxLayout;
        QMargins effectivenessMargins = effectivenessLayout->contentsMargins();
        effectivenessMargins.setTop(0);
        effectivenessMargins.setBottom(0);
        effectivenessLayout->setContentsMargins(effectivenessMargins);

        for (int i = 0; i < buttons.size(); i++)
          effectivenessLayout->addWidget(buttons[i]);

        controlsLayout->addLayout(effectivenessLayout);
      }
      else
      {
        for (int i = 0; i < buttons.size(); i++)
          delete buttons[i];
        delete effectivenessGroup;
        effectivenessGroup = NULL;
      }

      if (minForSuccess != -1)
      {
        QLabel * label = new QLabel;
        label->setText(
            "<span>Min Count<br/>for " + firstGroupEntry + "</span>");
        label->setFont(QFont("SansSerif", 7));
        QSpinBox * spinBox = new QSpinBox;
        spinBox->setRange(1, std::numeric_limits< int >::max());
        spinBox->setValue(1);  // FIXME: QSettings should handle this
        connect(spinBox, SIGNAL(valueChanged(int)),
            this, SLOT(updateMinForSuccess(int)));
        QHBoxLayout * minLayout = new QHBoxLayout;
        margins = minLayout->contentsMargins();
        margins.setTop(0);
        margins.setBottom(0);
        minLayout->setContentsMargins(margins);
        minLayout->addWidget(label);
        minLayout->addWidget(spinBox);
        minWidget = new QWidget;
        minWidget->setLayout(minLayout);

        controlsLayout->addWidget(minWidget);
        controlsLayout->setAlignment(minWidget, Qt::AlignTop);
        minWidget->setVisible(true); // FIXME: QSettings should handle this
      }
开发者ID:corburn,项目名称:ISIS,代码行数:99,代码来源:AbstractFilter.cpp

示例4: SynchronizeInterfaceWindow


//.........这里部分代码省略.........
		QList<QDoubleSpinBox *> widgetListDoubleSpinBox = window->findChildren<QDoubleSpinBox *>();
		QList<QDoubleSpinBox *>::iterator it;
		for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it)
		{
			QString name = (*it)->objectName();
			// qDebug() << "QDoubleSpinBox:" << (*it)->objectName() << " Type:" <<
			// (*it)->metaObject()->className() << endl;
			QString className = (*it)->metaObject()->className();
			if (name.length() > 1
					&& (className == QString("QDoubleSpinBox") || className == QString("MyDoubleSpinBox")))
			{
				QDoubleSpinBox *spinbox = *it;

				QString type, parameterName;
				GetNameAndType(name, &parameterName, &type);

				if (className == QString("MyDoubleSpinBox"))
				{
					MyDoubleSpinBox *mydoublespinbox = (MyDoubleSpinBox *)*it;
					mydoublespinbox->AssignParameterContainer(par);
					mydoublespinbox->AssignParameterName(parameterName);
				}

				if (type == QString("spinbox") || type == QString("spinboxd"))
				{
					if (mode == read)
					{
						double value = spinbox->value();
						par->Set(parameterName, value);
					}
					else if (mode == write)
					{
						double value = par->Get<double>(parameterName);
						spinbox->setValue(value);
					}
				}
				else if (type == QString("spinbox3") || type == QString("spinboxd3"))
				{
					char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1();
					QString nameVect = parameterName.left(parameterName.length() - 2);
					if (mode == read)
					{
						double value = spinbox->value();
						CVector3 vect = par->Get<CVector3>(nameVect);

						switch (lastChar)
						{
							case 'x': vect.x = value; break;

							case 'y': vect.y = value; break;

							case 'z': vect.z = value; break;

							default:
								qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " "
													 << nameVect << " has wrong axis name (is " << lastChar << ")" << endl;
								break;
						}
						par->Set(nameVect, vect);
					}
					else if (mode == write)
					{
						CVector3 vect = par->Get<CVector3>(nameVect);
						double value = 0;

						switch (lastChar)
开发者ID:BogusCurry,项目名称:mandelbulber2,代码行数:67,代码来源:synchronize_interface.cpp


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