本文整理汇总了C++中QDoubleValidator::setDecimals方法的典型用法代码示例。如果您正苦于以下问题:C++ QDoubleValidator::setDecimals方法的具体用法?C++ QDoubleValidator::setDecimals怎么用?C++ QDoubleValidator::setDecimals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDoubleValidator
的用法示例。
在下文中一共展示了QDoubleValidator::setDecimals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupAmountWidget
void setupAmountWidget(QLineEdit *widget, QWidget *parent)
{
QDoubleValidator *amountValidator = new QDoubleValidator(parent);
amountValidator->setDecimals(8);
amountValidator->setBottom(0.0);
widget->setValidator(amountValidator);
widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
}
示例2: setupAmountWidget
void setupAmountWidget(QLineEdit *widget, QWidget *parent)
{
QDoubleValidator *amountValidator = new QDoubleValidator(parent);
amountValidator->setDecimals(8);
amountValidator->setBottom(0.0);
widget->setValidator(amountValidator);
widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
widget->setStyleSheet("color: white; background: transparent");
}
示例3: QDialog
/*! Constructor */
AnalysisParameterDialog::AnalysisParameterDialog(QWidget* parent, const AnalysisInfo &analysisInfo) : QDialog(parent){
//Store variables
this->info = analysisInfo;
//Create layouts
QVBoxLayout* mainVerticalBox = new QVBoxLayout(this);
QGridLayout* gridLayout = new QGridLayout();
gridLayout->setMargin(10);
//Validators for double and integer parameters
QDoubleValidator* doubleValidator = new QDoubleValidator(this);
doubleValidator->setDecimals(5);
QIntValidator* intValidator = new QIntValidator(0, 50, this);
//Add the description
gridLayout->addWidget(new QLabel("Analysis description: "), 0, 0);
descriptionEdit = new QLineEdit(info.getDescription());
gridLayout->addWidget(descriptionEdit, 0, 1);
//Add the number of threads
gridLayout->addWidget(new QLabel("Number of simultaneous threads: "), 1, 0);
numThreadsEdit = new QLineEdit(QString::number(info.getNumberOfThreads()));
numThreadsEdit->setValidator(intValidator);
gridLayout->addWidget(numThreadsEdit, 1, 1);
//Add the parameters
int cntr = 2;
for(QHash<QString, double>::iterator iter = info.getParameterMap().begin(); iter != info.getParameterMap().end(); ++iter){
gridLayout->addWidget(new QLabel(iter.key()), cntr, 0);
QLineEdit* tmpEdit = new QLineEdit(QString::number(iter.value(), 'g', 10));//'g' sets the output similar to sprintf; 10 is the maximum precision
tmpEdit->setValidator(doubleValidator);
//Disable parameter editing if it is loaded from the database
if(analysisInfo.getID() != 0){
tmpEdit->setEnabled(false);
}
gridLayout->addWidget(tmpEdit, cntr, 1);
editMap[iter.key()] = tmpEdit;
++cntr;
}
mainVerticalBox->addLayout(gridLayout);
//Add Ok and Cancel buttons
QHBoxLayout *okCanButtonBox = new QHBoxLayout();
QPushButton *okPushButton = new QPushButton("Ok");
connect(okPushButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
QPushButton *cancelPushButton = new QPushButton("Cancel");
connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(reject()));
okCanButtonBox->addWidget(okPushButton);
okCanButtonBox->addWidget(cancelPushButton);
mainVerticalBox->addLayout(okCanButtonBox);
}
示例4: setupGui
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TiltAngleGroupBox::setupGui()
{
// Put a file path completer to help out the user to select a valid file
QFileCompleter* com = new QFileCompleter(this, false);
rawTltFile->setCompleter(com);
QObject::connect( com, SIGNAL(activated(const QString&)),
this, SLOT(on_rawTltFile_textChanged(const QString&)));
{
QDoubleValidator* dVal = new QDoubleValidator(this);
dVal->setDecimals(6);
startingAngle->setValidator(dVal);
}
{
QDoubleValidator* dVal = new QDoubleValidator(this);
dVal->setDecimals(6);
increment->setValidator(dVal);
}
rawTltBtn->toggle();
rawTltBtn->toggle();
noTilts->setChecked(true);
}
示例5: SubQLineEdit
QWidget *DynamicFloatControl::createEditor(QWidget* parent,
const QStyleOptionViewItem& option, const QModelIndex& index)
{
// create and init the edit box
mTemporaryEditControl = new SubQLineEdit(parent, this);
QDoubleValidator* validator = new QDoubleValidator(mTemporaryEditControl);
validator->setDecimals(NUM_DECIMAL_DIGITS_FLOAT);
mTemporaryEditControl->setValidator(validator);
if (!mInitialized)
{
LOG_ERROR("Tried to add itself to the parent widget before being initialized");
return mTemporaryEditControl;
}
updateEditorFromModel(mTemporaryEditControl);
mTemporaryEditControl->setToolTip(getDescription());
return mTemporaryEditControl;
}
示例6: QLineEdit
QWidget* GCF::Components::NumberEditorCreator::createEditor(QWidget* parent)
{
QLineEdit* lineEdit = new QLineEdit(parent);
lineEdit->setFrame(true);
QValidator* validator = 0;
if(mType == QVariant::Double)
{
QDoubleValidator* dv = new QDoubleValidator(lineEdit);
dv->setDecimals(2);
validator = dv;
}
else
{
QIntValidator* iv = new QIntValidator(lineEdit);
validator = iv;
}
lineEdit->setValidator(validator);
return lineEdit;
}
示例7: createEditor
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QWidget* DynamicTableItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
QLineEdit* editor = new QLineEdit(parent);
QDoubleValidator* validator = new QDoubleValidator();
validator->setDecimals(5);
validator->setNotation(QDoubleValidator::StandardNotation);
editor->setValidator(validator);
return editor;
}