本文整理汇总了C++中setValidator函数的典型用法代码示例。如果您正苦于以下问题:C++ setValidator函数的具体用法?C++ setValidator怎么用?C++ setValidator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setValidator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setValidator
void FractionInput::setAllowRange( bool allowRange )
{
m_allowRange = allowRange;
if ( allowRange ) {
setValidator( &m_rangeValidator );
} else {
setValidator( &m_numberValidator );
}
}
示例2: setValidator
/*
* Refreshes the validator used in QLineEdit depending on the options choosed by the user
*/
void SearchLineEdit::setRefreshValidator(ValidatorType validatorType)
{
if (validatorType == ectn_AUR_VALIDATOR)
setValidator(m_aurValidator);
else if (validatorType == ectn_FILE_VALIDATOR)
setValidator(m_fileValidator);
else if (validatorType == ectn_DEFAULT_VALIDATOR)
setValidator(m_defaultValidator);
//If the current string is not valid anymore, let's erase it!
int pos = 0;
QString search = text();
if (this->validator()->validate(search, pos) == QValidator::Invalid)
setText("");
}
示例3: QLineEdit
AdjustButton::AdjustButton (QWidget* parent, float change_rate) :
QLineEdit (parent),
rate (change_rate),
min (-std::numeric_limits<float>::max()),
max (std::numeric_limits<float>::max()),
is_min (false),
is_max (false),
deadzone_y (-1),
deadzone_value (NAN)
{
setValidator (new QDoubleValidator (this));
setToolTip (tr ("Click & drag to adjust"));
setAlignment (Qt::AlignRight);
connect (this, SIGNAL (editingFinished()), SLOT (onSetValue()));
installEventFilter (this);
setStyleSheet ((
"QLineEdit { "
"padding: 0.1em 20px 0.2em 0.3ex; "
"background: qlineargradient(x1:0, y1:0, x2:0, y2:0.2, stop:0 gray, stop:1 white) url(:/adjustbutton.svg); "
"background-position: right; "
"background-repeat: no-repeat; "
"font-size: " + str(font().pointSize()) + "pt; "
"border: 1px solid grey; "
"border-color: black lightgray white gray; "
"border-radius: 0.3em }").c_str());
}
示例4: TeacherQueryModel
std::pair<QSqlQueryModel *, RecordEditorWidget *>
TeacherForm::createModelAndEditor() {
const QVariantMap columnLabels = {
{"first_name", QObject::tr("First Name")},
{"last_name", QObject::tr("Last Name")},
{"email", QObject::tr("Email")},
{"rfid", QObject::tr("RFID")},
{"employee_number", QObject::tr("Employee Number")},
{"office", QObject::tr("Office Number")}};
TeacherQueryModel *model = new TeacherQueryModel(
columnLabels, QSqlDatabase::database(DEFAULT_DB_NAME));
const FieldTypes fieldTypes = {{"first_name", FieldType::LineEdit},
{"last_name", FieldType::LineEdit},
{"email", FieldType::LineEdit},
{"rfid", FieldType::LineEdit},
{"employee_number", FieldType::LineEdit},
{"office", FieldType::LineEdit}};
auto editor = new TeacherEditorWidget(fieldTypes);
editor->setupUi(columnLabels, model->record());
editor->setValidator(new TeacherValidator(editor->fieldTypes(),
editor->fieldEditors(), editor));
editor->clearData();
return make_pair<QSqlQueryModel *, RecordEditorWidget *>(model, editor);
}
示例5: changeShellTimeoutDialog
void changeShellTimeoutDialog()
{
auto changeShellTimeoutDialog = new QDialog;
auto settingsManager = AppRegistry::instance().settingsManager();
auto currentShellTimeout = new QLabel(QString::number(settingsManager->shellTimeoutSec()));
auto newShellTimeout = new QLineEdit;
newShellTimeout->setValidator(new QIntValidator(0, 100000));
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
QObject::connect(buttonBox, SIGNAL(accepted()), changeShellTimeoutDialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), changeShellTimeoutDialog, SLOT(reject()));
auto lay = new QGridLayout;
auto firstLabel = new QLabel("Enter new value for Robo 3T shell timeout in seconds:\n");
lay->addWidget(firstLabel, 0, 0, 1, 2, Qt::AlignLeft);
lay->addWidget(new QLabel("Current Value: "), 1, 0);
lay->addWidget(currentShellTimeout, 1, 1);
lay->addWidget(new QLabel("New Value: "), 2, 0);
lay->addWidget(newShellTimeout, 2, 1);
lay->addWidget(buttonBox, 3, 0, 1, 2, Qt::AlignRight);
changeShellTimeoutDialog->setLayout(lay);
changeShellTimeoutDialog->setWindowTitle("Robo 3T");
if (changeShellTimeoutDialog->exec()) {
settingsManager->setShellTimeoutSec(newShellTimeout->text().toInt());
settingsManager->save();
auto subStr = settingsManager->shellTimeoutSec() > 1 ? " seconds." : " second.";
LOG_MSG("Shell timeout value changed from " + currentShellTimeout->text() + " to " +
QString::number(settingsManager->shellTimeoutSec()) + subStr, mongo::logger::LogSeverity::Info());
for (auto server : AppRegistry::instance().app()->getServers())
server->changeWorkerShellTimeout(std::abs(newShellTimeout->text().toInt()));
}
}
示例6: QLineEdit
PlaceEdit::PlaceEdit(PlaceEdit *_parent, int _index, QString placeholderText, QWidget *qparent)
: QLineEdit(qparent)
{
qDebug() << "creating place edit";
setMaxLength(40);
setPlaceholderText(placeholderText);
m_model = new PlaceModel(_index, this);
m_completer = new QCompleter(m_model, this);
m_completer->setCaseSensitivity(Qt::CaseInsensitive);
// TODO put in mask
// TODO prevent slashes
m_completer->setModel(m_model);
setCompleter(m_completer);
setValidator(new LineValidator(this));
if (_parent) {
connect(_parent->model(), SIGNAL(valueChanged(QString)), m_model, SLOT(onParentTextChanged(QString)));
connect(_parent->model(), SIGNAL(valueChanged(QString)), this, SLOT(onParentTextChanged(QString)));
}
}
示例7: QLineEdit
IntegerEdit::IntegerEdit()
: QLineEdit()
{
val = new IntegerValidator;
setValidator(val);
setToolTip(tr("Enter an integer or bool\n0x... for hex, 0b... for binary"));
}
示例8: NameEditor
/* Constructor: */
NameEditor(QWidget *pParent = 0) : QLineEdit(pParent)
{
setFrame(false);
setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setValidator(new QRegExpValidator(QRegExp("[^,:]*"), this));
connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(sltTextEdited(const QString&)));
}
示例9: QLineEdit
QIPEdit::QIPEdit(QWidget *parent)
: QLineEdit(parent)
{
ui.setupUi(this);
setValidator(new QIPValidator(this));
}
示例10: WLineEdit
WDateEdit::WDateEdit(WContainerWidget *parent)
: WLineEdit(parent)
{
changed().connect(this, &WDateEdit::setFromLineEdit);
const char *TEMPLATE = "${calendar}";
WTemplate *t = new WTemplate(WString::fromUTF8(TEMPLATE));
popup_ = new WPopupWidget(t, this);
popup_->setAnchorWidget(this);
popup_->setTransient(true);
calendar_ = new WCalendar();
calendar_->activated().connect(popup_, &WPopupWidget::hide);
calendar_->activated().connect(this, &WDateEdit::setFocus);
calendar_->selectionChanged().connect(this, &WDateEdit::setFromCalendar);
t->bindWidget("calendar", calendar_);
WApplication::instance()->theme()->apply(this, popup_, DatePickerPopupRole);
t->escapePressed().connect(popup_, &WTemplate::hide);
t->escapePressed().connect(this, &WDateEdit::setFocus);
setValidator(new WDateValidator("dd/MM/yyyy", this));
}
示例11: QComboBox
// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
// Difficult to get all in one...
// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
KTimeEdit::KTimeEdit(QWidget *parent, QTime qt, const char *name)
: QComboBox(true, parent, name)
{
setInsertionPolicy(NoInsertion);
setValidator(new KOTimeValidator(this));
mTime = qt;
// mNoTimeString = i18n("No Time");
// insertItem( mNoTimeString );
// Fill combo box with selection of times in localized format.
QTime timeEntry(0, 0, 0);
do
{
insertItem(KGlobal::locale()->formatTime(timeEntry));
timeEntry = timeEntry.addSecs(60 * 15);
}
while(!timeEntry.isNull());
// Add end of day.
insertItem(KGlobal::locale()->formatTime(QTime(23, 59, 59)));
updateText();
setFocusPolicy(QWidget::StrongFocus);
connect(this, SIGNAL(activated(int)), this, SLOT(active(int)));
connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(changedText()));
}
示例12: scroll
QcNumberBox::QcNumberBox()
: scroll( true ),
lastPos( 0 ),
editedTextColor( QColor( "red" ) ),
normalTextColor( palette().color(QPalette::Text) ),
_validator( new QDoubleValidator( this ) ),
step( 0.1f ),
scrollStep( 1.0f ),
dragDist( 10.f ),
_value( 0. ),
_valueType( Number ),
_minDec(0),
_maxDec(2)
{
_validator->setDecimals( _maxDec );
setValidator( _validator );
// Do not display thousands separator. It only eats up precious space.
QLocale loc( locale() );
loc.setNumberOptions( QLocale::OmitGroupSeparator );
setLocale( loc );
setLocked( true );
connect( this, SIGNAL( editingFinished() ),
this, SLOT( onEditingFinished() ) );
connect( this, SIGNAL( valueChanged() ),
this, SLOT( updateText() ), Qt::QueuedConnection );
setValue( 0 );
}
示例13: QLineEdit
DoubleEdit::DoubleEdit(QWidget* parent)
: QLineEdit(parent)
{
QDoubleValidator* validator = new QDoubleValidator(-DBL_MAX, DBL_MAX, 3, this);
setValidator(validator);
setMaximumWidth(60);
setValue(0.0);
}
示例14: KLineEdit
FractionInput::FractionInput( QWidget *parent, MixedNumber::Format format ) : KLineEdit( parent ),
m_allowRange(false),
m_format(format)
{
//setAlignment( Qt::AlignRight );
setValidator( &m_numberValidator );
}
示例15: QLineEdit
DateEdit::DateEdit(QWidget *parent)
: QLineEdit(parent)
{
setValidator(new DateValidator(this));
#if COMPAT_QT_VERSION >= 0x030200
setInputMask("00/00/0000;_");
#endif
}