本文整理汇总了C++中QDoubleValidator类的典型用法代码示例。如果您正苦于以下问题:C++ QDoubleValidator类的具体用法?C++ QDoubleValidator怎么用?C++ QDoubleValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDoubleValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: QLineEdit
QWidget*CoordinateItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& index ) const
{
QLineEdit* lineEdit = new QLineEdit( parent );
QDoubleValidator* validator = new QDoubleValidator();
if ( !index.data( MinRadiusRole ).isNull() )
validator->setBottom( index.data( MinRadiusRole ).toDouble() );
lineEdit->setValidator( validator );
return lineEdit;
}
示例3: 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");
}
示例4: tr
bool Ruler::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget)
{
bool result = PaletteItem::collectExtraInfo(parent, family, prop, value, swappingEnabled, returnProp, returnValue, returnWidget);
if (prop.compare("width", Qt::CaseInsensitive) == 0) {
returnProp = tr("width");
int units = m_modelPart->localProp("width").toString().contains("cm") ? IndexCm : IndexIn;
QLineEdit * e1 = new QLineEdit();
QDoubleValidator * validator = new QDoubleValidator(e1);
validator->setRange(1.0, 20 * ((units == IndexCm) ? 2.54 : 1), 2);
validator->setNotation(QDoubleValidator::StandardNotation);
e1->setValidator(validator);
e1->setEnabled(swappingEnabled);
QString temp = m_modelPart->localProp("width").toString();
temp.chop(2);
e1->setText(temp);
e1->setObjectName("infoViewLineEdit");
e1->setMaximumWidth(80);
m_widthEditor = e1;
m_widthValidator = validator;
QComboBox * comboBox = new QComboBox(parent);
comboBox->setEditable(false);
comboBox->setEnabled(swappingEnabled);
comboBox->addItem("cm");
comboBox->addItem("in");
comboBox->setCurrentIndex(units);
m_unitsEditor = comboBox;
comboBox->setObjectName("infoViewComboBox");
comboBox->setMinimumWidth(60);
QHBoxLayout * hboxLayout = new QHBoxLayout();
hboxLayout->setAlignment(Qt::AlignLeft);
hboxLayout->setContentsMargins(0, 0, 0, 0);
hboxLayout->setSpacing(0);
hboxLayout->setMargin(0);
hboxLayout->addWidget(e1);
hboxLayout->addWidget(comboBox);
QFrame * frame = new QFrame();
frame->setLayout(hboxLayout);
frame->setObjectName("infoViewPartFrame");
connect(e1, SIGNAL(editingFinished()), this, SLOT(widthEntry()));
connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(unitsEntry(const QString &)));
returnValue = temp + QString::number(units);
returnWidget = frame;
return true;
}
示例5: switch
void PropertyEditDelegate::setModelData(QWidget* editor_,
QAbstractItemModel* model_,
const QModelIndex& index) const
{
const QVariant& data = index.data();
GeneratorPropertiesModel* model =
static_cast<GeneratorPropertiesModel*>(model_);
switch (data.type())
{
case QVariant::Double:
{
QLineEdit* editor = static_cast<QLineEdit*>(editor_);
model->setData(index, editor->text().toDouble(), Qt::EditRole);
break;
}
case QVariant::Int:
{
QSpinBox* editor = static_cast<QSpinBox*>(editor_);
editor->interpretText();
model->setData(index, editor->value(), Qt::EditRole);
break;
}
case QVariant::Bool:
{
QCheckBox* editor = static_cast<QCheckBox*>(editor_);
const bool value = editor->checkState() == Qt::Checked;
model->setData(index, value, Qt::EditRole);
break;
}
case QVariant::List:
{
QLineEdit* editor = static_cast<QLineEdit*>(editor_);
QStringList list = editor->text().split(",");
QVariantList varList;
QDoubleValidator validator;
for (QString& str : list)
{
if (str == "")
continue;
int pos = 0;
if (validator.validate(str, pos) == QValidator::Acceptable)
varList.push_back(QVariant(str.toDouble()));
else
varList.push_back(QVariant(-1.0));
}
model->setData(index, varList, Qt::EditRole);
break;
}
default:
{
break;
}
}
}
示例6: QAbstractScrollArea
TrackView::TrackView(SyncPage *page, QWidget *parent) :
QAbstractScrollArea(parent),
page(page),
windowRows(0),
readOnly(false),
dragging(false)
{
Q_ASSERT(page);
lineEdit = new QLineEdit(this);
lineEdit->setAutoFillBackground(true);
lineEdit->hide();
QDoubleValidator *lineEditValidator = new QDoubleValidator();
lineEditValidator->setNotation(QDoubleValidator::StandardNotation);
lineEditValidator->setLocale(QLocale::c());
lineEdit->setValidator(lineEditValidator);
QObject::connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()));
viewport()->setAutoFillBackground(false);
setFocus(Qt::OtherFocusReason);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollPosX = 0;
scrollPosY = 0;
editRow = 0;
editTrack = 0;
selectionStart = selectionEnd = QPoint(0, 0);
updateFont(fontMetrics());
updatePalette();
stepPen = QPen();
lerpPen = QPen(QBrush(Qt::red), 2);
smoothPen = QPen(QBrush(Qt::green), 2);
rampPen = QPen(QBrush(Qt::blue), 2);
editBrush = Qt::yellow;
bookmarkBrush = QColor(128, 128, 255);
handCursor = QCursor(Qt::OpenHandCursor);
setMouseTracking(true);
setupScrollBars();
QObject::connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onHScroll(int)));
QObject::connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVScroll(int)));
QObject::connect(page, SIGNAL(trackHeaderChanged(int)), this, SLOT(onTrackHeaderChanged(int)));
QObject::connect(page, SIGNAL(trackDataChanged(int, int, int)), this, SLOT(onTrackDataChanged(int, int, int)));
}
示例7: 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);
}
示例8: QDialog
/* Dialog box for editing location parameters: central body,
* latitude, longitude, and altitude.
*/
LocationEditorDialog::LocationEditorDialog(QWidget* parent) :
QDialog(parent)
{
setupUi(this);
// Set up the input validators
QDoubleValidator* doubleValidator = new QDoubleValidator(this);
QDoubleValidator* angleValidator = new QDoubleValidator(this);
angleValidator->setBottom(-360.0);
angleValidator->setTop(360.0);
latitudeEdit->setValidator(angleValidator);
longitudeEdit->setValidator(angleValidator);
altitudeEdit->setValidator(doubleValidator);
}
示例9: QGAbstractAppParamInput
// Default constructor
QGAppParamInputReal::QGAppParamInputReal(qgar::QgarAppParamDescr * descr,
QGAppDialogMediator * med,
QWidget * parent,
QGridLayout * layout)
: QGAbstractAppParamInput(descr, med, parent, layout)
{
//-- create value box and validator
_value = new QLineEdit(this);
QDoubleValidator * valid = new QDoubleValidator(_value);
_value->setValidator(valid);
_value->setAlignment(Qt::AlignRight);
_value->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,
QSizePolicy::Maximum));
//-- Set value bounds and default value
if (_descr->defaultValue() != "")
_value->setText(_descr->defaultValue().c_str());
double val;
bool ok;
val = QString(_descr->minValue().c_str()).toDouble(&ok);
if (ok)
valid->setBottom(val);
val = QString(_descr->maxValue().c_str()).toDouble(&ok);
if (ok)
valid->setTop(val);
this->setEnabled(enabled());
_layout->addWidget(_value);
// Connect line edit to the slot that fwds notification to the
// mediator
connect(_value,
SIGNAL(textChanged(const QString&)),
SLOT(valueChanged()));
}
示例10: validateDlg
/*!
This checks the validators to make sure the number of friction cone vectors
and the dynamic time step are within their ranges. If they aren't, a
warning box explaining the problem is created. Otherwise, the dialog
is closed and accepted.
*/
void SettingsDlg::validateDlg()
{
int zero=0;
QString tst = dlgUI->timeStepLine->text();
QString msg;
QDoubleValidator *tsv = (QDoubleValidator *)dlgUI->timeStepLine->validator();
if (tsv->validate(tst,zero) != QValidator::Acceptable) {
msg = QString("Dynamic time step must be between %1 and %2").arg(tsv->bottom()).arg(tsv->top());
}
if (!msg.isEmpty()) {
QMessageBox::warning(NULL,"GraspIt!",msg,QMessageBox::Ok, Qt::NoButton,Qt::NoButton);
} else {
dlgImpl->accept();
}
}
示例11: UpdateConfigRangeValidator
void ICParameterRange::UpdateConfigRangeValidator(uint type, double min, double max)
{
if(!configsRangeCache_.contains(type)) return;
QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(type));
if(dv != NULL)
{
dv->setBottom(min);
dv->setTop(max);
return;
}
QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(type));
if(iv != NULL)
{
iv->setBottom(min);
iv->setTop(max);
}
}
示例12: QDialog
transmitterPayloadDialog::transmitterPayloadDialog( QWidget * parent, Qt::WindowFlags f) : QDialog(parent,f)
{
setupUi(this);
QDoubleValidator* positiveDoubleValidator = new QDoubleValidator(this);
positiveDoubleValidator->setBottom(0.0);
QDoubleValidator* efficiencyValidator = new QDoubleValidator(this);
efficiencyValidator->setBottom(0.0);
efficiencyValidator->setTop(100.0);
// changed this to range -90, 90 to turn antennas also in direction of space (need it for ground stations with antennas)
QDoubleValidator* elevationValidator = new QDoubleValidator(this);
elevationValidator->setRange(-90, 90, 2);
ElLineEdit->setValidator(elevationValidator);
//ElLineEdit->setValidator(positiveDoubleValidator);
TxFeederLossLineEdit->setValidator(positiveDoubleValidator);
TxDepointingLossLineEdit->setValidator(positiveDoubleValidator);
GainLineEdit->setValidator(positiveDoubleValidator);
DiameterLineEdit->setValidator(positiveDoubleValidator);
BeamLineEdit->setValidator(positiveDoubleValidator);
TiltLineEdit->setValidator(positiveDoubleValidator);
EfficiencyLineEdit->setValidator(efficiencyValidator);
FrequencyLineEdit->setValidator(positiveDoubleValidator);
PowerLineEdit->setValidator(positiveDoubleValidator);
DataRateLineEdit->setValidator(positiveDoubleValidator);
ConeAngleLineEdit->setValidator(positiveDoubleValidator);
HorAngleLineEdit->setValidator(positiveDoubleValidator);
VertAngleLineEdit->setValidator(positiveDoubleValidator);
}
示例13: if
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TextureDialog::setupGui()
{
if(Ebsd::CrystalStructure::Check::IsCubic(m_CrystalStructure) )
{
m_Presets = CubicTexturePresets::getTextures();
}
else if(Ebsd::CrystalStructure::Check::IsHexagonal(m_CrystalStructure) )
{
m_Presets = HexTexturePresets::getTextures();
}
// Clear the list view;
presetListWidget->clear();
// Now push the list into the List View
for (TexturePreset::Container::iterator iter = m_Presets.begin(); iter != m_Presets.end(); ++iter)
{
presetListWidget->addItem(QString::fromStdString((*iter)->getName()));
}
{
QDoubleValidator* validator = new QDoubleValidator(euler1);
validator->setDecimals(4);
euler1->setValidator(validator);
}
{
QDoubleValidator* validator = new QDoubleValidator(euler2);
validator->setDecimals(4);
euler2->setValidator(validator);
}
{
QDoubleValidator* validator = new QDoubleValidator(euler3);
validator->setDecimals(4);
euler3->setValidator(validator);
}
{
QDoubleValidator* validator = new QDoubleValidator(weight);
validator->setDecimals(4);
weight->setValidator(validator);
}
{
sigma->setRange(1.0, 1.0);
if (Ebsd::CrystalStructure::Check::IsCubic(m_CrystalStructure ) )
{
sigma->setRange(1.0, 18.0);
}
else if (Ebsd::CrystalStructure::Check::IsHexagonal(m_CrystalStructure) )
{
sigma->setRange(1.0, 36.0);
}
}
}
示例14: qPow
void ICParameterRange::UpdateConfigRangeValidator(const ICAddrWrapper *addr, double value)
{
// QMap<const ICAddrWrapper*, uint>::iterator p = addrToMaxValidator_.find(addr);
value /= qPow(10, addr->Decimal());
QList<uint> vs = addrToMaxValidator_.values(addr);
for(int i = 0; i != vs.size(); ++i)
{
if(!configsRangeCache_.contains(vs.at(i))) continue;
QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(vs.at(i)));
if(dv != NULL)
{
dv->setTop(value);
// ++p;
continue;
}
QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(vs.at(i)));
if(iv != NULL)
{
iv->setTop(value);
}
}
vs = addrToMinValidator_.values(addr);
for(int i = 0; i != vs.size(); ++i)
{
if(!configsRangeCache_.contains(vs.at(i))) continue;
QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(vs.at(i)));
if(dv != NULL)
{
dv->setBottom(value);
// ++p;
continue;
}
QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(vs.at(i)));
if(iv != NULL)
{
iv->setBottom(value);
}
}
}
示例15: QWidget
GeoReverse::GeoReverse(QWidget *parent) :
QWidget(parent),
ui(new Ui::GeoReverse)
{
ui->setupUi(this);
m_oauthTwitter = new OAuthTwitter(this);
m_oauthTwitter->setNetworkAccessManager(new QNetworkAccessManager(this));
m_oauthTwitter->setOAuthToken("");
m_oauthTwitter->setOAuthTokenSecret("");
QDoubleValidator *latValidator = new QDoubleValidator(ui->latitudeLineEdit);
latValidator->setNotation(QDoubleValidator::StandardNotation);
ui->latitudeLineEdit->setValidator(latValidator);
QDoubleValidator *longValidator = new QDoubleValidator(ui->longitudeLineEdit);
longValidator->setNotation(QDoubleValidator::StandardNotation);
ui->longitudeLineEdit->setValidator(longValidator);
connect(ui->searchPushButton, SIGNAL(clicked()), SLOT(onSearchPushButtonClicked()));
}