本文整理汇总了C++中QSpinBox类的典型用法代码示例。如果您正苦于以下问题:C++ QSpinBox类的具体用法?C++ QSpinBox怎么用?C++ QSpinBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSpinBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEditorData_TYPE
void Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
if ( index.column() == COLUMN_TYPE ){
setEditorData_TYPE(editor,index);return;
}
if ( index.column() == COLUMN_KEY_INV ){
setEditorData_KEY_INV(editor,index);return;
}
if ( index.column() == COLUMN_TAGE_LAMP || index.column() == COLUMN_TAGE_KEY ||
index.column() == COLUMN_TAGE_TIT){
setEditorData_LEdit(editor,index);return;
}
int value = index.model()->data(index, Qt::EditRole).toInt();
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->setValue(value);
}
示例2: switch
void FormDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
const CGeorgesFormProxyModel * mp = dynamic_cast<const CGeorgesFormProxyModel *>(index.model());
const CGeorgesFormModel * m = dynamic_cast<const CGeorgesFormModel *>(mp->sourceModel());
const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType();
int numDefinitions = type->getNumDefinition();
QString value = index.model()->data(index, Qt::DisplayRole).toString();
if (numDefinitions)
{
QComboBox *cb = static_cast<QComboBox*>(editor);
cb->setCurrentIndex(cb->findText(value));
//cb->setIconSize()
}
else
{
switch (type->getType())
{
case NLGEORGES::UType::UnsignedInt:
case NLGEORGES::UType::SignedInt:
{
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->setValue((int)value.toDouble());
break;
}
case NLGEORGES::UType::Double:
{
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
spinBox->setValue(value.toDouble());
break;
}
case NLGEORGES::UType::Color:
{
break;
}
default:
{
QLineEdit *textEdit = static_cast<QLineEdit*>(editor);
textEdit->setText(value);
break;
}
}
}
}
示例3: saveLimits
void Moto::saveLimits( QSettings & set )
{
QStringList names;
QList<QSpinBox *> boxes;
names << "maxThrottleCwMin" << "maxThrottleCwMax" << "maxThrottleCwVal"
<< "maxThrottleCcwMin" << "maxThrottleCcwMax" << "maxThrottleCcwVal"
<< "maxSpeedCwMin" << "maxSpeedCwMax" << "maxSpeedCwVal"
<< "maxSpeedCcwMin" << "maxSpeedCcwMax" << "maxSpeedCcwVal"
<< "throttleRampUpCwMin" << "throttleRampUpCwMax" << "throttleRampUpCwVal"
<< "throttleRampUpCcwMin" << "throttleRampUpCcwMax" << "throttleRampUpCcwVal"
<< "throttleRampDownCwMin" << "throttleRampDownCwMax" << "throttleRampDownCwVal"
<< "throttleRampDownCcwMin" << "throttleRampDownCcwMax" << "throttleRampDownCcwVal"
<< "stallThresholdMin" << "stallThresholdMax" << "stallThresholdVal"
<< "undervoltageCtrlMin" << "undervoltageCtrlMax" << "undervoltageCtrlVal"
<< "motorOvertempMin" << "motorOvertempMax" << "motorOvertempVal"
<< "controllerOvertempMin" << "cotrollerOvertempMax" << "controllerOvertempVal";
boxes << ui.maxThrottleCw << ui.maxThrottleCcw << ui.maxSpeedCw << ui.maxSpeedCcw
<< ui.throttleRampUpCw << ui.throttleRampUpCcw << ui.throttleRampDownCw << ui.throttleRampDownCcw
<< ui.stallThreshold << ui.undervoltageCtrl << ui.motorOvertemp << ui.controllerOvertemp;
int index = 0;
int cnt = boxes.size();
for ( int i=0; i<cnt; i++ )
{
QSpinBox * s = boxes[i];
int f = s->minimum();
int t = s->maximum();
int v = s->value();
QString from = names.at( index );
QString to = names.at( index+1 );
QString val = names.at( index+2 );
index += 3;
set.setValue( from, f );
set.setValue( to, t );
set.setValue( val, v );
}
int v = ui.throttleMode->currentIndex();
set.setValue( "throttleModeVal", v );
v = ui.throttleType->currentIndex();
set.setValue( "throttleTypeVal", v );
v = ui.commutationMode->currentIndex();
set.setValue( "commutationModeVal", v );
v = set.value( "currentLimitVal", 0 ).toInt();
ui.currentLimit->setCurrentIndex( v );
}
示例4: switch
void StatusDelegate::setModelData(QWidget *AEditor, QAbstractItemModel *AModel, const QModelIndex &AIndex) const
{
bool allowEmptyText = true;
switch (AIndex.data(STR_COLUMN).toInt())
{
case STC_NAME:
allowEmptyText = false;
case STC_MESSAGE:
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(AEditor);
if (lineEdit && (allowEmptyText || !lineEdit->text().trimmed().isEmpty()))
{
QString data = lineEdit->text();
AModel->setData(AIndex,data,Qt::DisplayRole);
AModel->setData(AIndex,data,STR_VALUE);
}
break;
}
case STC_STATUS:
{
QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
if (comboBox)
{
int data = comboBox->itemData(comboBox->currentIndex()).toInt();
AModel->setData(AIndex,FStatusChanger->iconByShow(data),Qt::DecorationRole);
AModel->setData(AIndex,FStatusChanger->nameByShow(data),Qt::DisplayRole);
AModel->setData(AIndex,data,STR_VALUE);
}
break;
}
case STC_PRIORITY:
{
QSpinBox *spinBox = qobject_cast<QSpinBox *>(AEditor);
if (spinBox)
{
int data = spinBox->value();
AModel->setData(AIndex,data,Qt::DisplayRole);
AModel->setData(AIndex,data,STR_VALUE);
}
break;
}
default:
QStyledItemDelegate::setModelData(AEditor,AModel,AIndex);
}
}
示例5: QComboBox
QWidget *TableDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() == 0) // figure type
{
QComboBox *combo_editor;
combo_editor = new QComboBox(parent);
combo_editor->addItem(tr("Piramid"));
combo_editor->addItem(tr("Prisme"));
return combo_editor;
}
else if (index.column() == 1 || index.column() == 5) // base type
{
QLabel *l_base = new QLabel(parent);
return l_base;
}
else if (index.column() == 2) // hight
{
QSpinBox *editor = new QSpinBox(parent);
editor->setMinimum(0);
editor->setMaximum(1000);
return editor;
}
else if (index.column() == 3) // hight possicion
{
QRegExp rx;
rx.setPattern("(\\([0-9\\-][0-9]{0,6},[0-9\\-][0-9]{0,6},[0-9\\-][0-9]{0,6}\\)){1,1}");
QRegExpValidator *validator = new QRegExpValidator(rx);
QLineEdit *editor = new QLineEdit(parent);
editor->setValidator(validator);
QString currentText = index.model()->data(index, Qt::DisplayRole).toString();
editor->setText(currentText);
return editor;
}
else //if (index.column() == 4) // base points
{
QRegExp rx;
rx.setPattern("(\\([0-9\\-][0-9]{0,6},[0-9\\-][0-9]{0,6},[0-9\\-][0-9]{0,6}\\)){0," + max_number_sites + "}");
QRegExpValidator *validator = new QRegExpValidator(rx);
QLineEdit *editor = new QLineEdit(parent);
editor->setValidator(validator);
QString currentText = index.model()->data(index, Qt::DisplayRole).toString();
editor->setText(currentText);
return editor;
}
}
示例6: it
/*!
\fn newViewDialog::slotPluginSelected()
*/
void newViewDialog::slotPluginSelected()
{
QString name = pluginsList->currentItem()->text();
okPushButton->setEnabled( TRUE );
QListIterator<pluginData> it(pl);
while( it.hasNext() ){
pluginData data = it.next();
if ( data.name == name ){
maxSelect = data.numChannels;
int comediSubdevice = comedi_find_subdevice_by_type(comediDevice,data.type_comedi,0);
if( comediSubdevice >= 0){
maxChannels = comedi_get_n_channels(comediDevice, comediSubdevice);
okPushButton->setEnabled(TRUE);
status->setText(QString("comedi subdevice\ntype %1 found!").arg(data.type_comedi));
}
else{
//comedi_perror( QString("error in %1 line %2").arg(__func__).arg(__LINE__).toStdString().c_str() );
okPushButton->setEnabled(FALSE);
maxChannels = 0;
status->setText(QString("comedi subdevice\ntype %1 not found!").arg(data.type_comedi));
}
if( maxChannels < 0 ){
maxChannels = 0;
comedi_perror( QString("error in %1 line %2").arg(__func__).arg(__LINE__).toStdString().c_str() );
}
if(channelSelectors.count() < maxSelect)
for( int i = channelSelectors.count(); i < maxSelect; i++ ) {
QSpinBox *spinBox = new QSpinBox();
spinBox->setRange( 0, maxChannels-1 );
channelsListL->addWidget( spinBox );
channelSelectors << spinBox ;
}
else if(channelSelectors.count() > maxSelect) {
channelSelectors.last();
for( int i = maxSelect; i< channelSelectors.count(); i++ )
delete channelSelectors.takeLast();
}
}
}
}
示例7: updateUnits
void ColumnList::updateUnits()
{
// Replace widget suffices and table headers
for(Column *col : columns)
{
col->colDisplayName = Unit::replacePlaceholders(col->colOrigDisplayName);
QSpinBox *sb = col->getSpinBoxWidget();
if(sb != nullptr)
sb->setSuffix(Unit::replacePlaceholders(sb->suffix(), col->colWidgetSuffix));
sb = col->getMinSpinBoxWidget();
if(sb != nullptr)
sb->setSuffix(Unit::replacePlaceholders(sb->suffix(), col->colMinWidgetSuffix));
sb = col->getMaxSpinBoxWidget();
if(sb != nullptr)
sb->setSuffix(Unit::replacePlaceholders(sb->suffix(), col->colMaxWidgetSuffix));
}
if(minDistanceWidget != nullptr)
minDistanceWidget->setSuffix(
Unit::replacePlaceholders(minDistanceWidget->suffix(), minDistanceWidgetSuffix));
if(maxDistanceWidget != nullptr)
maxDistanceWidget->setSuffix(
Unit::replacePlaceholders(maxDistanceWidget->suffix(), maxDistanceWidgetSuffix));
}
示例8: switch
QWidget *reDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *parent) const
{
switch (type) {
case QVariant::Bool: {
QBooleanComboBox *cb = new QBooleanComboBox(parent);
return cb;
}
case QVariant::UInt: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMaximum(INT_MAX);
return sb;
}
case QVariant::Int: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
sb->setMaximum(INT_MAX);
return sb;
}
case QVariant::Date: {
QDateTimeEdit *ed = new QDateEdit(parent);
ed->setFrame(false);
return ed;
}
case QVariant::Time: {
QDateTimeEdit *ed = new QTimeEdit(parent);
ed->setFrame(false);
return ed;
}
case QVariant::DateTime: {
QDateTimeEdit *ed = new QDateTimeEdit(parent);
ed->setFrame(false);
return ed;
}
case QVariant::Pixmap:
return new QLabel(parent);
case QVariant::Double: {
QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
sb->setMaximum(DBL_MAX);
return sb;
}
case QVariant::StringList: {
QComboBox* cb = new QComboBox(parent);
return cb;
}
case QVariant::String:
default: {
// the default editor is a lineedit
QLineEdit *le = new QLineEdit(parent);
//le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
//if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le))
//le->setWidgetOwnsGeometry(true);
return le;
}
}
return 0;
}
示例9: newFile
void MainWindow::newFile()
{
QSpinBox *width = new QSpinBox;
QSpinBox *height = new QSpinBox;
QCheckBox *transparentBackground = new QCheckBox(tr("Transparent background"));
QDialog *dialog = createNewFileDialog(width, height, transparentBackground);
int ans = dialog->exec();
if (ans == QDialog::Accepted)
{
int w = width->value();
int h = height->value();
newFile(w, h, transparentBackground->isChecked());
}
delete dialog;
}
示例10: ChacheSizeSetter
void UIPropertySetters::ChacheSizeSetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType propertyType, QVariant propertyValue)
{
if (editorType == SettingsPropertyMapper::SPINBOX)
{
QSpinBox* pSpinBox = qobject_cast<QSpinBox*>(editor);
if (pSpinBox == NULL)
{
qCritical() << "SpinboxKBSetter support only ChacheSizeSetter. Unable to cast to ChacheSizeSetter.";
return;
}
int val = propertyValue.toInt();
pSpinBox->setValue(val * 16);
}
else
{
qCritical() << "SpinboxKBSetter support only ChacheSizeSetter";
}
}
示例11: itEditor
void QtSpinBoxFactory::slotRangeChanged(QtProperty *property, int min, int max)
{
if (!m_createdEditors.contains(property))
return;
QtIntPropertyManager *manager = this->propertyManager(property);
if (!manager)
return;
QListIterator<QSpinBox *> itEditor(m_createdEditors[property]);
while (itEditor.hasNext()) {
QSpinBox *editor = itEditor.next();
editor->blockSignals(true);
editor->setRange(min, max);
editor->setValue(manager->value(property));
editor->blockSignals(false);
}
}
示例12: new_spin_box
QSpinBox* new_spin_box (QBoxLayout *layout, const QString &label, int min, int max, int value, int step)
{
QHBoxLayout *lt_h = new QHBoxLayout;
QLabel *l = new QLabel (label);
QSpinBox *r = new QSpinBox;
r->setSingleStep (step);
r->setRange (min, max);
r->setValue (value);
lt_h->addWidget (l);
lt_h ->addWidget (r);
layout->addLayout (lt_h);
return r;
}
示例13: QSpinBox
/*!
Create and return the box used to modify number of states.
*/
QSpinBox* UiDigitalGenerator::createStatesBox()
{
GeneratorDevice* device = DeviceManager::instance().activeDevice()
->generatorDevice();
// Deallocation:
// Toolbar takes ownership when adding this box by call to
// toolBar->addWidget(mStatesBox) in createToolBar
QSpinBox* box = new QSpinBox();
box->setToolTip(tr("The number of digital states to use"));
box->setRange(2, device->maxNumDigitalStates());
connect(box, SIGNAL(valueChanged(int)), this, SLOT(setNumStates(int)));
return box;
}
示例14: create_integer_input
QSpinBox* RenderSettingsWindow::create_integer_input(
const string& widget_key,
const int min,
const int max,
const QString& label)
{
QSpinBox* spinbox = create_integer_input(widget_key, min, max);
const QString suffix = " " + label;
spinbox->setSuffix(suffix);
QString text;
text.setNum(max);
text.append(suffix);
set_widget_width_for_text(spinbox, text, SpinBoxMargin, SpinBoxMinWidth);
return spinbox;
}
示例15:
void x264ZoneTableDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
int value;
if (index.column() == 2)
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
value = comboBox->currentIndex();
}
else
{
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->interpretText();
value = spinBox->value();
}
model->setData(index, value, Qt::EditRole);
}