本文整理汇总了C++中QDoubleSpinBox类的典型用法代码示例。如果您正苦于以下问题:C++ QDoubleSpinBox类的具体用法?C++ QDoubleSpinBox怎么用?C++ QDoubleSpinBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDoubleSpinBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: valeChanged
void FormJqgzcs::valeChanged(QWidget *obj){
QSpinBox *spinbox = qobject_cast<QSpinBox *>(obj);
if(spinbox){
int val = spinbox->value();
int index = spinbox->property("index").toInt();
param->setData(QParam::SpaItemHd_Jqgzcs,index,val);
if(14==index)
pcomm->yajiaoTest(Md::POSFRONT,4,val);
if(15==index)
pcomm->yajiaoTest(Md::POSREAR,4,val);
return;
}
QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox *>(obj);
if(doublespinbox){
int val =doublespinbox->value()*10;
int index = doublespinbox->property("index").toInt();
param->setData(QParam::SpaItemHd_Jqgzcs,index,val);
return;
}
QPushButton *pushbutton = qobject_cast<QPushButton *>(obj);
if(pushbutton){
int val =pushbutton->isChecked();
int index = pushbutton->property("index").toInt();
param->setData(QParam::SpaItemHd_Jqgzcs,index,val);
return;
}
}
示例2: connect
void ShaderSelector::addUniform(QGridLayout* settings, const QString& section, const QString& name, float* value, float min, float max, int y, int x) {
QDoubleSpinBox* f = new QDoubleSpinBox;
f->setDecimals(3);
if (min < max) {
f->setMinimum(min);
f->setMaximum(max);
}
float def = *value;
bool ok = false;
float v = m_config->getQtOption(name, section).toFloat(&ok);
if (ok) {
*value = v;
}
f->setValue(*value);
f->setSingleStep(0.001);
f->setAccelerated(true);
settings->addWidget(f, y, x);
connect(f, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [value](double v) {
*value = v;
});
connect(this, &ShaderSelector::saved, [this, section, name, f]() {
m_config->setQtOption(name, f->value(), section);
});
connect(this, &ShaderSelector::reset, [this, section, name, f]() {
bool ok = false;
float v = m_config->getQtOption(name, section).toFloat(&ok);
if (ok) {
f->setValue(v);
}
});
connect(this, &ShaderSelector::resetToDefault, [def, section, name, f]() {
f->setValue(def);
});
}
示例3: ExpectNameNotFound
void ParamWidget::AddDouble(const QString& name,
double min, double max, double step, double initial_value,
DisplayHint display_hint) {
ExpectNameNotFound(name);
if (display_hint == DisplayHint::kSpinBox) {
QDoubleSpinBox* spinbox = new QDoubleSpinBox(this);
spinbox->setRange(min, max);
spinbox->setSingleStep(step);
spinbox->setValue(initial_value);
spinbox->setProperty("param_widget_type", kParamDouble);
widgets_[name] = spinbox;
AddLabeledRow(name, spinbox);
connect(spinbox,
static_cast<void(QDoubleSpinBox::*)(double)>(
&QDoubleSpinBox::valueChanged),
[this, name](double value) {
emit ParamChanged(name);
});
} else if (display_hint == DisplayHint::kSlider) {
QWidget* row_widget = new QWidget(this);
QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
QSlider* slider = new QSlider(Qt::Horizontal, this);
const int num_steps = static_cast<int>((max - min) / step);
const int initial_value_int =
static_cast<int>((initial_value - min) / step);
slider->setRange(0, num_steps);
slider->setSingleStep(1);
slider->setValue(initial_value_int);
slider->setProperty("min", min);
slider->setProperty("max", max);
slider->setProperty("step", step);
slider->setProperty("param_widget_type", kParamDouble);
QLabel* label = new QLabel(this);
label->setText(QString::number((initial_value_int - min) * step));
row_hbox->addWidget(new QLabel(name, this));
row_hbox->addWidget(slider);
row_hbox->addWidget(label);
widgets_[name] = slider;
layout_->addWidget(row_widget);
slider->setProperty("param_widget_label", QVariant::fromValue(label));
label->setProperty("format_str", "");
connect(slider, &QSlider::valueChanged,
[this, name, label, min, step](int position) {
const double value = min + step * position;
const QString format_str = label->property("format_str").toString();
if (format_str == "") {
label->setText(QString::number(value));
label->setMinimumWidth(std::max(label->width(), label->minimumWidth()));
} else {
QString text;
text.sprintf(format_str.toStdString().c_str(), value);
label->setText(text);
}
emit ParamChanged(name);
});
} else {
throw std::invalid_argument("Invalid display hint");
}
}
示例4: switch
void EventDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
switch(index.column()) {
case 0: {
int value = index.model()->data(index, Qt::DisplayRole).toInt();
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->setValue(value);
break;
}
case 1: {
double value = index.model()->data(index, Qt::DisplayRole).toDouble();
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
spinBox->setValue(value);
break;
}
case 2: {
int value = index.model()->data(index, Qt::DisplayRole).toInt();
QComboBox *spinBox = static_cast<QComboBox*>(editor);
spinBox->setCurrentText(QString().number(value));
break;
}
}
}
示例5: kvp
void PreferencesDlg::setConfig()
{
LayeredConfiguration &config = BasicApplication::instance().config();
// Iterate over the _configMap and set the widgets' values to whatever the
// configuration says depending on the respective widget type.
QMutableMapIterator<QWidget *, const char *> kvp(_configMap);
while (kvp.hasNext()) {
kvp.next();
if (kvp.key()->inherits("QCheckBox")) {
QCheckBox *cb = static_cast<QCheckBox*>(kvp.key());
config.setBool(kvp.value(), cb->isChecked());
}
else if (kvp.key()->inherits("QComboBox")) {
QComboBox *cb = static_cast<QComboBox*>(kvp.key());
config.setInt(kvp.value(), cb->currentIndex());
}
else if (kvp.key()->inherits("QSpinBox")) {
QSpinBox *sb = static_cast<QSpinBox*>(kvp.key());
config.setInt(kvp.value(), sb->value());
}
else if (kvp.key()->inherits("QDoubleSpinBox")) {
QDoubleSpinBox *dsb = static_cast<QDoubleSpinBox*>(kvp.key());
config.setDouble(kvp.value(), dsb->value());
}
else {
throw Poco::NotImplementedException("Unknown configuration widget.");
}
}
}
示例6: getGuiValue
virtual dyn_t getGuiValue(void){
QAbstractButton *button = dynamic_cast<QAbstractButton*>(_widget);
if (button!=NULL)
return DYN_create_bool(button->isChecked());
QAbstractSlider *slider = dynamic_cast<QAbstractSlider*>(_widget);
if (slider!=NULL)
return DYN_create_int(slider->value());
QLabel *label = dynamic_cast<QLabel*>(_widget);
if (label!=NULL)
return DYN_create_string(label->text());
QLineEdit *line_edit = dynamic_cast<QLineEdit*>(_widget);
if (line_edit!=NULL)
return DYN_create_string(line_edit->text());
QTextEdit *text_edit = dynamic_cast<QTextEdit*>(_widget);
if (text_edit!=NULL)
return DYN_create_string(text_edit->toPlainText());
QSpinBox *spinbox = dynamic_cast<QSpinBox*>(_widget);
if (spinbox!=NULL)
return DYN_create_int(spinbox->value());
QDoubleSpinBox *doublespinbox = dynamic_cast<QDoubleSpinBox*>(_widget);
if (doublespinbox!=NULL)
return DYN_create_float(doublespinbox->value());
handleError("Gui #%d does not have a getValue method", _gui_num);
return DYN_create_bool(false);
}
示例7: 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;
}
示例8: if
QWidget* DynamicObjectItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
if (index.column() == 1)
{
auto node = (DynamicObjectModel::Node*)index.internalPointer();
if (!node)
{
return QStyledItemDelegate::createEditor(parent, option, index);
}
if (node->onCreateEditor)
{
return node->onCreateEditor(parent, option);
}
else if (node->m_getter().type() == QMetaType::Bool)
{
return nullptr;
}
else if (node->m_getter().type() == QMetaType::Float)
{
QDoubleSpinBox* input = new QDoubleSpinBox(parent);
input->setMaximum(FLT_MAX);
input->setMinimum(-FLT_MAX);
connect(input, (void (QDoubleSpinBox::*)(double))&QDoubleSpinBox::valueChanged, [node](double value){
node->m_setter(value);
});
input->setSingleStep(0.1);
return input;
}
}
return QStyledItemDelegate::createEditor(parent, option, index);
}
示例9: QCOMPARE
void tst_QItemDelegate::doubleEditorNegativeInput()
{
QStandardItemModel model;
QStandardItem *item = new QStandardItem;
item->setData(10.0, Qt::DisplayRole);
model.appendRow(item);
QListView view;
view.setModel(&model);
view.show();
QModelIndex index = model.index(0, 0);
view.setCurrentIndex(index); // the editor will only selectAll on the current index
view.edit(index);
QList<QDoubleSpinBox*> editors = qFindChildren<QDoubleSpinBox *>(view.viewport());
QCOMPARE(editors.count(), 1);
QDoubleSpinBox *editor = editors.at(0);
QCOMPARE(editor->value(), double(10));
QTest::keyClick(editor, Qt::Key_Minus);
QTest::keyClick(editor, Qt::Key_1);
QTest::keyClick(editor, Qt::Key_0);
QTest::keyClick(editor, Qt::Key_Comma); //support both , and . locales
QTest::keyClick(editor, Qt::Key_Period);
QTest::keyClick(editor, Qt::Key_0);
QTest::keyClick(editor, Qt::Key_Enter);
QApplication::processEvents();
QCOMPARE(index.data().toString(), QString("-10"));
}
示例10: switch
void LoanAssumptionDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
if (!index.data(Qt::UserRole).isNull()) {
switch (index.data(Qt::UserRole).toInt()) {
case static_cast<qint8>(AssumptionType::DoubleAssumption) :
case static_cast<qint8>(AssumptionType::DoubleAssumption0To100) : {
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
spinBox->interpretText();
model->setData(index, spinBox->value(), Qt::EditRole);
break;
}
case static_cast<qint8>(AssumptionType::IntegerAssumption) : {
QSpinBox *spinBox = qobject_cast<QSpinBox*>(editor);
spinBox->interpretText();
model->setData(index, spinBox->value(), Qt::EditRole);
break;
}
case static_cast<qint8>(AssumptionType::BloombergVectorAssumption) :
case static_cast<qint8>(AssumptionType::IntegerVectorAssumption) :
case static_cast<qint8>(AssumptionType::DayCountVectorAssumption) :
model->setData(index, qobject_cast<QLineEdit*>(editor)->text(), Qt::EditRole);
break;
default:
model->setData(index, QVariant(), Qt::EditRole);
}
}
else model->setData(index, QVariant(), Qt::EditRole);
}
示例11:
void
pcl::modeler::DoubleParameter::getEditorData(QWidget *editor)
{
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
double value = spinBox->text().toDouble();
current_value_ = value;
}
示例12: fillInputTableData
bool ElacticMapAnalyzer::showDialog() {
fillInputTableData();
StatisticAnalyzeDialog *dialog = new StatisticAnalyzeDialog();
dialog->SetDialogName(name);
dialog->addAdditionalParam(new QSpinBox(), "Количество итераций");
dialog->addAdditionalParam(new QSpinBox(), tr("P"));
dialog->addAdditionalParam(new QSpinBox(), tr("Q"));
QDoubleSpinBox* muSP = new QDoubleSpinBox();
muSP->setMaximum(10000);
dialog->addAdditionalParam(muSP, tr("Mu"));
QDoubleSpinBox* lambdaSP = new QDoubleSpinBox();
lambdaSP->setMaximum(10000);
dialog->addAdditionalParam(lambdaSP, tr("Lambda"));
QHashIterator<QString,QString> iterator(this->getAllParams());
while (iterator.hasNext()) {
iterator.next();
dialog->addAviabledParam(iterator.value(), iterator.key());
}
dialog->exec();
if (dialog->ParametersList->count()==0) {
return false;
}
parametersList = dialog->ParametersList;
p = dialog->GetIntParam("P");
q = dialog->GetIntParam("Q");
pq = p*q;
iterations = dialog->GetIntParam("Количество итераций");
lambda = dialog->GetDoubleParam("Lambda");
mu = dialog->GetDoubleParam("Mu");
return true;
}
示例13: QDoubleSpinBox
QWidget *OffersDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() == 4 ) return QSqlRelationalDelegate::createEditor(parent, option, index);
else {
QWidget *editor = NULL;
QDoubleSpinBox *dSpinbox = new QDoubleSpinBox(parent);
QDateEdit *dateEdit = new QDateEdit(parent);
switch(index.column())
{
case 1: //discount
editor = dSpinbox;
dSpinbox->setMinimum(0);
dSpinbox->setMaximum(99.99);
dSpinbox->setSuffix(" %");
break;
case 2: //date
editor = dateEdit;
break;
case 3: //date
editor = dateEdit;
break;
default : //Never must be here...
break;
}
return editor;
}
}
示例14: staticSetWidgetData
void DoubleDataInformationMethods::staticSetWidgetData(double value, QWidget* w)
{
QDoubleSpinBox* spin = qobject_cast<QDoubleSpinBox*> (w);
Q_CHECK_PTR(spin);
if (spin)
spin->setValue(value);
}
示例15: QWidget
void MainWindow::addSpinBoxes(bool checked, int count, Range range)
{
if (checked) {
QWidget *w = new QWidget(ui->quantifierValuesGroupBox);
if (ui->quantifierValuesGroupBox->layout() == 0) {
QHBoxLayout *hbl = new QHBoxLayout(ui->quantifierValuesGroupBox);
ui->quantifierValuesGroupBox->setLayout(hbl);
}
ui->quantifierValuesGroupBox->layout()->addWidget(w);
QFormLayout *fl = new QFormLayout(w);
for (int i = 0; i < count; i++) {
QAbstractSpinBox *asb;
if (range == Absolute) {
QSpinBox *sb = new QSpinBox(w);
sb->setMinimum(0);
sb->setMaximum(10000);
asb = sb;
} else {
QDoubleSpinBox *sb = new QDoubleSpinBox(w);
sb->setMinimum(0);
sb->setMaximum(1);
sb->setSingleStep(0.05);
asb = sb;
}
fl->addRow(QString(QChar('A' + i)), asb);
}
} else {
QLayout *fl = ui->quantifierValuesGroupBox->layout();
if (fl != nullptr && fl->count() > 0) {
QWidget *w = fl->takeAt(0)->widget();
delete w;
// there is no mem-leak here, qt handles qobject's children by itself
}
}
}