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); }
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"); }
/*! 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); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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); }
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; }
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; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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; }