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


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

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


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

示例1: main

int main(int argc, char *argv[]){
	QApplication app(argc, argv);
	
	QWidget *window = new QWidget;
	window->setWindowTitle("Enter Your Age");
	
	QSpinBox *spinBox = new QSpinBox;
	QSlider *slider = new QSlider(Qt::Horizontal);
	spinBox->setRange(0, 130);
	slider->setRange(0, 130);
	
	QObject::connect(spinBox, SIGNAL(valueChanged(int)),
		slider, SLOT(setValue(int)));
	QObject::connect(slider, SIGNAL(valueChanged(int)),
		spinBox, SLOT(setValue(int)));
	spinBox->setValue(35);
	
	QHBoxLayout *layout = new QHBoxLayout;
	layout->addWidget(spinBox);
	layout->addWidget(slider);
	window->setLayout(layout);
	
	window->show();
	
	return app.exec();	
}
开发者ID:padhikari,项目名称:qt,代码行数:26,代码来源:widget.cpp

示例2: displayProperties

void VCMatrixPresetSelection::displayProperties(RGBScript *script)
{
    if (script == NULL)
        return;

    int gridRowIdx = 0;

    QList<RGBScriptProperty> properties = script->properties();
    if (properties.count() > 0)
        m_propertiesGroup->show();
    else
        m_propertiesGroup->hide();

    foreach(RGBScriptProperty prop, properties)
    {
        switch(prop.m_type)
        {
            case RGBScriptProperty::List:
            {
                QLabel *propLabel = new QLabel(prop.m_displayName);
                m_propertiesLayout->addWidget(propLabel, gridRowIdx, 0);
                QComboBox *propCombo = new QComboBox(this);
                propCombo->addItems(prop.m_listValues);
                propCombo->setProperty("pName", prop.m_name);
                QString pValue = script->property(prop.m_name);
                if (!pValue.isEmpty())
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
                    propCombo->setCurrentText(pValue);
#else
                    propCombo->setCurrentIndex(propCombo->findText(pValue));
#endif
                connect(propCombo, SIGNAL(currentIndexChanged(QString)),
                        this, SLOT(slotPropertyComboChanged(QString)));
                m_propertiesLayout->addWidget(propCombo, gridRowIdx, 1);
                gridRowIdx++;
            }
            break;
            case RGBScriptProperty::Range:
            {
                QLabel *propLabel = new QLabel(prop.m_displayName);
                m_propertiesLayout->addWidget(propLabel, gridRowIdx, 0);
                QSpinBox *propSpin = new QSpinBox(this);
                propSpin->setRange(prop.m_rangeMinValue, prop.m_rangeMaxValue);
                propSpin->setProperty("pName", prop.m_name);
                QString pValue = script->property(prop.m_name);
                if (!pValue.isEmpty())
                    propSpin->setValue(pValue.toInt());
                connect(propSpin, SIGNAL(valueChanged(int)),
                        this, SLOT(slotPropertySpinChanged(int)));
                m_propertiesLayout->addWidget(propSpin, gridRowIdx, 1);
                gridRowIdx++;
            }
            break;
            default:
                qWarning() << "Type" << prop.m_type << "not handled yet";
            break;
        }
    }
}
开发者ID:Cingulingu,项目名称:qlcplus,代码行数:59,代码来源:vcmatrixpresetselection.cpp

示例3: QSpinBox

QWidget *spinDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                                    const QModelIndex &index) const
{
    QSpinBox *editor = new QSpinBox(parent);
    editor->setRange(0, 10000);
    editor->installEventFilter(const_cast<spinDelegate *>(this));
    return editor;
}
开发者ID:DchunWang,项目名称:myFirst,代码行数:8,代码来源:spindelegate.cpp

示例4: SIGNAL

QWidget *ProcessingCropBelowLevel::createGUI(void)
{
	QSpinBox *spinBox = new QSpinBox;
	spinBox->setRange(0, 32767);
	spinBox->setValue(level);
	connect(spinBox, SIGNAL(valueChanged(int)), SLOT(levelChanged(int)));
	return spinBox;
}
开发者ID:gpiszczek,项目名称:osqoop,代码行数:8,代码来源:CropBelowLevel.cpp

示例5: QLabel

//! [0]
MainWindow::MainWindow()
{
    selectedDate = QDate::currentDate();
    fontSize = 10;

    QWidget *centralWidget = new QWidget;
//! [0]

//! [1]
    QLabel *dateLabel = new QLabel(tr("Date:"));
    QComboBox *monthCombo = new QComboBox;

    for (int month = 1; month <= 12; ++month)
        monthCombo->addItem(QDate::longMonthName(month));

    QDateTimeEdit *yearEdit = new QDateTimeEdit;
    yearEdit->setDisplayFormat("yyyy");
    yearEdit->setDateRange(QDate(1753, 1, 1), QDate(8000, 1, 1));
//! [1]

    monthCombo->setCurrentIndex(selectedDate.month() - 1);
    yearEdit->setDate(selectedDate);

//! [2]
    QLabel *fontSizeLabel = new QLabel(tr("Font size:"));
    QSpinBox *fontSizeSpinBox = new QSpinBox;
    fontSizeSpinBox->setRange(1, 64);
    fontSizeSpinBox->setValue(10);

    editor = new QTextBrowser;
    insertCalendar();
//! [2]

//! [3]
    connect(monthCombo, SIGNAL(activated(int)), this, SLOT(setMonth(int)));
    connect(yearEdit, SIGNAL(dateChanged(QDate)), this, SLOT(setYear(QDate)));
    connect(fontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(setFontSize(int)));
//! [3]

//! [4]
    QHBoxLayout *controlsLayout = new QHBoxLayout;
    controlsLayout->addWidget(dateLabel);
    controlsLayout->addWidget(monthCombo);
    controlsLayout->addWidget(yearEdit);
    controlsLayout->addSpacing(24);
    controlsLayout->addWidget(fontSizeLabel);
    controlsLayout->addWidget(fontSizeSpinBox);
    controlsLayout->addStretch(1);

    QVBoxLayout *centralLayout = new QVBoxLayout;
    centralLayout->addLayout(controlsLayout);
    centralLayout->addWidget(editor, 1);
    centralWidget->setLayout(centralLayout);

    setCentralWidget(centralWidget);
//! [4]
}
开发者ID:cedrus,项目名称:qt4,代码行数:59,代码来源:mainwindow.cpp

示例6: createDoubleSpinBoxes

void Window::createDoubleSpinBoxes() {
  doubleSpinBoxesGroup = new QGroupBox(tr("Double precision spinboxes"));

  QLabel *precisionLabel = new QLabel(tr("Number of decimal places to show:"));
  QSpinBox *precisionSpinBox = new QSpinBox;
  precisionSpinBox->setRange(0, 100);
  precisionSpinBox->setValue(2);

  QLabel *doubleLabel =
      new QLabel(tr("Enter a value between %1 and %2:").arg(-20).arg(20));
  doubleSpinBox = new QDoubleSpinBox;
  doubleSpinBox->setRange(-20.0, 20.0);
  doubleSpinBox->setSingleStep(1.0);
  doubleSpinBox->setValue(0.0);

  QLabel *scaleLabel = new QLabel(
      tr("Enter a scale factor between %1 and %2:").arg(0).arg(1000.0));
  scaleSpinBox = new QDoubleSpinBox;
  scaleSpinBox->setRange(0.0, 1000.0);
  scaleSpinBox->setSingleStep(10.0);
  scaleSpinBox->setSuffix("%");
  scaleSpinBox->setSpecialValueText(tr("No scaling"));
  scaleSpinBox->setValue(100.0);

  QLabel *priceLabel =
      new QLabel(tr("Enter a price between %1 and %2:").arg(0).arg(1000));
  priceSpinBox = new QDoubleSpinBox;
  priceSpinBox->setRange(0.0, 1000.0);
  priceSpinBox->setSingleStep(1.0);
  priceSpinBox->setPrefix(tr("$"));
  priceSpinBox->setValue(99.99);
  connect(precisionSpinBox, SIGNAL(valueChanged(int)), this,
          SLOT(changePrecision(int)));

  groupSeparatorSpinBox_d = new QDoubleSpinBox;
  groupSeparatorSpinBox_d->setRange(-99999999, 99999999);
  groupSeparatorSpinBox_d->setDecimals(2);
  groupSeparatorSpinBox_d->setValue(1000.00);
  groupSeparatorSpinBox_d->setGroupSeparatorShown(true);
  QCheckBox *groupSeparatorChkBox = new QCheckBox;
  groupSeparatorChkBox->setText(tr("Show group separator"));
  groupSeparatorChkBox->setChecked(true);
  connect(groupSeparatorChkBox, &QCheckBox::toggled, groupSeparatorSpinBox_d,
          &QDoubleSpinBox::setGroupSeparatorShown);

  QVBoxLayout *spinBoxLayout = new QVBoxLayout;
  spinBoxLayout->addWidget(precisionLabel);
  spinBoxLayout->addWidget(precisionSpinBox);
  spinBoxLayout->addWidget(doubleLabel);
  spinBoxLayout->addWidget(doubleSpinBox);
  spinBoxLayout->addWidget(scaleLabel);
  spinBoxLayout->addWidget(scaleSpinBox);
  spinBoxLayout->addWidget(priceLabel);
  spinBoxLayout->addWidget(priceSpinBox);
  spinBoxLayout->addWidget(groupSeparatorChkBox);
  spinBoxLayout->addWidget(groupSeparatorSpinBox_d);
  doubleSpinBoxesGroup->setLayout(spinBoxLayout);
}
开发者ID:Jinxiaohai,项目名称:QT,代码行数:58,代码来源:window.cpp

示例7: createEditor

QWidget* IntProperty::createEditor( QWidget* parent,
                                    const QStyleOptionViewItem& option )
{
  QSpinBox* editor = new QSpinBox( parent );
  editor->setFrame( false );
  editor->setRange( min_, max_ );
  connect( editor, SIGNAL( valueChanged( int )), this, SLOT( setInt( int )));
  return editor;
}
开发者ID:CURG,项目名称:rviz,代码行数:9,代码来源:int_property.cpp

示例8: moduleSetsW

AddD::AddD(Settings &sets, QWidget *parent, QObject *moduleSetsW) :
	QDialog(parent), moduleSetsW(moduleSetsW), sets(sets), hzW(NULL)
{
	QGroupBox *gB = NULL;
	if (parent)
	{
		setWindowTitle(tr("Tone generator"));
		setWindowIcon(QIcon(":/sine"));
	}
	else
		gB = new QGroupBox(tr("Tone generator"));

	QLabel *channelsL = new QLabel(tr("Channel count") + ": ");

	QSpinBox *channelsB = new QSpinBox;
	connect(channelsB, SIGNAL(valueChanged(int)), this, SLOT(channelsChanged(int)));

	QLabel *srateL = new QLabel(tr("Sample rate") + ": ");

	srateB = new QSpinBox;
	srateB->setRange(4, 384000);
	srateB->setSuffix(" Hz");
	srateB->setValue(sets.getInt("ToneGenerator/srate"));

	QDialogButtonBox *bb = NULL;
	QPushButton *addB = NULL;
	if (parent)
	{
		bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
		connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
		connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
	}
	else
	{
		addB = new QPushButton(tr("Play"));
		addB->setIcon(QIcon(":/sine"));
		connect(addB, SIGNAL(clicked()), this, SLOT(add()));
	}

	layout = new QGridLayout(parent ? (QWidget *)this : (QWidget *)gB);
	layout->addWidget(channelsL, 0, 0, 1, 1);
	layout->addWidget(channelsB, 0, 1, 1, 1);
	layout->addWidget(srateL, 1, 0, 1, 1);
	layout->addWidget(srateB, 1, 1, 1, 1);
	if (parent)
		layout->addWidget(bb, 3, 0, 1, 2);
	else
	{
		layout->addWidget(addB, 3, 0, 1, 2);
		QGridLayout *layout = new QGridLayout(this);
		layout->setMargin(0);
		layout->addWidget(gB);
	}

	channelsB->setRange(1, 8);
	channelsB->setValue(sets.getString("ToneGenerator/freqs").split(',').count());
}
开发者ID:mitya57,项目名称:QMPlay2,代码行数:57,代码来源:Inputs.cpp

示例9: createDoubleSpinBoxes

//! [14]
void Window::createDoubleSpinBoxes()
{
    doubleSpinBoxesGroup = new QGroupBox(tr("Double precision spinboxes"));

    QLabel *precisionLabel = new QLabel(tr("Number of decimal places "
                                           "to show:"));
    QSpinBox *precisionSpinBox = new QSpinBox;
    precisionSpinBox->setRange(0, 100);
    precisionSpinBox->setValue(2);
//! [14]

//! [15]
    QLabel *doubleLabel = new QLabel(tr("Enter a value between "
        "%1 and %2:").arg(-20).arg(20));
    doubleSpinBox = new QDoubleSpinBox;
    doubleSpinBox->setRange(-20.0, 20.0);
    doubleSpinBox->setSingleStep(1.0);
    doubleSpinBox->setValue(0.0);
//! [15]

//! [16]
    QLabel *scaleLabel = new QLabel(tr("Enter a scale factor between "
        "%1 and %2:").arg(0).arg(1000.0));
    scaleSpinBox = new QDoubleSpinBox;
    scaleSpinBox->setRange(0.0, 1000.0);
    scaleSpinBox->setSingleStep(10.0);
    scaleSpinBox->setSuffix("%");
    scaleSpinBox->setSpecialValueText(tr("No scaling"));
    scaleSpinBox->setValue(100.0);
//! [16]

//! [17]
    QLabel *priceLabel = new QLabel(tr("Enter a price between "
        "%1 and %2:").arg(0).arg(1000));
    priceSpinBox = new QDoubleSpinBox;
    priceSpinBox->setRange(0.0, 1000.0);
    priceSpinBox->setSingleStep(1.0);
    priceSpinBox->setPrefix("$");
    priceSpinBox->setValue(99.99);

    connect(precisionSpinBox, SIGNAL(valueChanged(int)),
//! [17]
            this, SLOT(changePrecision(int)));

//! [18]
    QVBoxLayout *spinBoxLayout = new QVBoxLayout;
    spinBoxLayout->addWidget(precisionLabel);
    spinBoxLayout->addWidget(precisionSpinBox);
    spinBoxLayout->addWidget(doubleLabel);
    spinBoxLayout->addWidget(doubleSpinBox);
    spinBoxLayout->addWidget(scaleLabel);
    spinBoxLayout->addWidget(scaleSpinBox);
    spinBoxLayout->addWidget(priceLabel);
    spinBoxLayout->addWidget(priceSpinBox);
    doubleSpinBoxesGroup->setLayout(spinBoxLayout);
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:57,代码来源:window.cpp

示例10: if

TtipMelody::TtipMelody(TquestionPoint *point) :
    TtipChart(point)
{
    setBgColor(point->color());
    setPlainText(" ");

    m_w = new QWidget();
    m_w->setObjectName("m_melodyView");
    m_w->setStyleSheet("QWidget#m_melodyView { background: transparent }");
    QString txt;
    if (point->nr())
        txt = QString(TquestionAsWdg::questionTxt() + " <big><b>%1.</b></big>").arg(point->nr());
    if (point->question()->questionAsNote() && point->question()->answerAsSound())
        txt += (" <b>" + TexTrans::playMelodyTxt() + "</b>");
    else if (point->question()->questionAsSound() && point->question()->answerAsNote())
        txt += (" <b>" + TexTrans::writeMelodyTxt() + "</b>");
    QLabel *headLab = new QLabel(txt, m_w);
    headLab->setAlignment(Qt::AlignCenter);
    m_score = new TmelodyView(qa()->question()->melody(), m_w);
    m_score->setFixedHeight(qApp->desktop()->availableGeometry().height() / 12);
    if (point->question()->exam()) {
        if (point->question()->exam()->level()->showStrNr)
            m_score->showStringNumbers(true);
    }
    QSpinBox *spinAtt = new QSpinBox(m_w);
    spinAtt->setRange(0, qa()->question()->attemptsCount());
    spinAtt->setPrefix(TexTrans::attemptTxt() + " ");
    spinAtt->setSuffix(" " + tr("of", "It will give text: 'Attempt x of y'") + QString(" %1").arg(qa()->question()->attemptsCount()));
    m_attemptLabel = new QLabel(m_w);
    m_resultLabel = new QLabel(wasAnswerOKtext(point->question(), point->color()).replace("<br>", " "), m_w);
    m_resultLabel->setAlignment(Qt::AlignCenter);
//   txt = wasAnswerOKtext(point->question(), point->color()).replace("<br>", " ") + "<br>";
    txt = tr("Melody was played <b>%n</b> times", "", qa()->question()->totalPlayBacks()) + "<br>";
    txt += TexTrans::effectTxt() + QString(": <big><b>%1%</b></big>, ").arg(point->question()->effectiveness(), 0, 'f', 1, '0');
    txt += TexTrans::reactTimeTxt() + QString("<big><b>  %1</b></big>").arg(Texam::formatReactTime(point->question()->time, true));
    QLabel *sumLab = new QLabel(txt, m_w);
    sumLab->setAlignment(Qt::AlignCenter);

    QVBoxLayout *lay = new QVBoxLayout;
    lay->addWidget(headLab);
    lay->addWidget(m_score, 0, Qt::AlignCenter);
    QHBoxLayout *attLay = new QHBoxLayout;
    attLay->addStretch();
    attLay->addWidget(spinAtt);
    attLay->addStretch();
    lay->addLayout(attLay);
    lay->addWidget(m_attemptLabel);
    lay->addWidget(m_resultLabel);
    lay->addWidget(sumLab);

    m_w->setLayout(lay);
    m_widget = point->scene()->addWidget(m_w);
    m_widget->setParentItem(this);

    connect(spinAtt, SIGNAL(valueChanged(int)), this, SLOT(attemptChanged(int)));
}
开发者ID:SeeLook,项目名称:nootka,代码行数:56,代码来源:ttipmelody.cpp

示例11: QSpinBox

QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
                                       const QStyleOptionViewItem &/* option */,
                                       const QModelIndex &/* index */) const
{
    QSpinBox *editor = new QSpinBox(parent);
    editor->setRange(0, 1000000);
    connect(editor, SIGNAL(valueChanged(int)), SIGNAL(sbd_valueChanged(int)));
    connect(editor, SIGNAL(editingFinished()), SIGNAL(sbd_editingFinished()));
    return editor;
}
开发者ID:sashoalm,项目名称:TesseractBoxEditor,代码行数:10,代码来源:delegateeditors.cpp

示例12: setEditorData

void SpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    int value = index.model()->data(index, Qt::EditRole).toInt();
    int min = index.model()->data(index, Role::Minimum).toInt();
    int max = index.model()->data(index, Role::Maximum).toInt();

    QSpinBox *box = static_cast<QSpinBox*>(editor);
    box->setRange( min, max );
    box->setValue( value );
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:10,代码来源:kptitemmodelbase.cpp

示例13: createSpinBoxes

//! [1]
void Window::createSpinBoxes()
{
    spinBoxesGroup = new QGroupBox(tr("Spinboxes"));

    QLabel *integerLabel = new QLabel(tr("Enter a value between "
        "%1 and %2:").arg(-20).arg(20));
    QSpinBox *integerSpinBox = new QSpinBox;
    integerSpinBox->setRange(-20, 20);
    integerSpinBox->setSingleStep(1);
    integerSpinBox->setValue(0);
//! [1]

//! [2]
    QLabel *zoomLabel = new QLabel(tr("Enter a zoom value between "
        "%1 and %2:").arg(0).arg(1000));
//! [3]
    QSpinBox *zoomSpinBox = new QSpinBox;
    zoomSpinBox->setRange(0, 1000);
    zoomSpinBox->setSingleStep(10);
    zoomSpinBox->setSuffix("%");
    zoomSpinBox->setSpecialValueText(tr("Automatic"));
    zoomSpinBox->setValue(100);
//! [2] //! [3]

//! [4]
    QLabel *priceLabel = new QLabel(tr("Enter a price between "
        "%1 and %2:").arg(0).arg(999));
    QSpinBox *priceSpinBox = new QSpinBox;
    priceSpinBox->setRange(0, 999);
    priceSpinBox->setSingleStep(1);
    priceSpinBox->setPrefix("$");
    priceSpinBox->setValue(99);
//! [4] //! [5]

    QVBoxLayout *spinBoxLayout = new QVBoxLayout;
    spinBoxLayout->addWidget(integerLabel);
    spinBoxLayout->addWidget(integerSpinBox);
    spinBoxLayout->addWidget(zoomLabel);
    spinBoxLayout->addWidget(zoomSpinBox);
    spinBoxLayout->addWidget(priceLabel);
    spinBoxLayout->addWidget(priceSpinBox);
    spinBoxesGroup->setLayout(spinBoxLayout);
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:44,代码来源:window.cpp

示例14: QSpinBox

QWidget *SpinBoxItem::createEditor() const
{
    // create a spinbox editor
    QSpinBox *spinbox = new QSpinBox(table()->viewport());
    spinbox->setSuffix(" ns");
    if (field_ == OFFSET) {
        spinbox->setRange(-1, INT_MAX);
        spinbox->setValue(node_->autoOffset() ? -1 : (int)node_->offset());
        spinbox->setSpecialValueText
            (QString("Auto (%1 ns)").arg(node_->offset()));
    }
    else {
        spinbox->setRange(0, INT_MAX);
        spinbox->setValue(field_ == CLOCK
                           ? node_->clock()
                           : node_->runtime());
    }

    return spinbox;
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:20,代码来源:scheduledialog.cpp

示例15: QSpinBox

QWidget *
CQPropertyIntegerEditor::
createEdit(QWidget *parent)
{
  QSpinBox *spin = new QSpinBox(parent);

  spin->setRange(min_, max_);
  spin->setSingleStep(step_);

  return spin;
}
开发者ID:colinw7,项目名称:CQPropertyTree,代码行数:11,代码来源:CQPropertyEditor.cpp


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