本文整理汇总了C++中QRegExpValidator::setRegExp方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExpValidator::setRegExp方法的具体用法?C++ QRegExpValidator::setRegExp怎么用?C++ QRegExpValidator::setRegExp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExpValidator
的用法示例。
在下文中一共展示了QRegExpValidator::setRegExp方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bgLineChangeRegExp
// set line regexp
void MainWindow::bgLineChangeRegExp(int index)
{
QRegExpValidator *validator = new QRegExpValidator(bgColorLine);
switch (index)
{
case 0 : // hex rgb16
{
bgRedLabel->hide();
bgRedBox->hide();
bgGreenLabel->hide();
bgGreenBox->hide();
bgBlueLabel->hide();
bgBlueBox->hide();
bgColorLine->show();
validator->setRegExp(QRegExp("0x[0-9A-Fa-f]{1,4}"));
bgColorLine->setValidator(validator);
bgColorLine->setText(convertShortToQString(
convertQColorToShort(bgColor)));
break;
}
case 1 : // hex rgb24
{
bgRedLabel->hide();
bgRedBox->hide();
bgGreenLabel->hide();
bgGreenBox->hide();
bgBlueLabel->hide();
bgBlueBox->hide();
bgColorLine->show();
validator->setRegExp(QRegExp("0x[0-9A-Fa-f]{1,6}"));
bgColorLine->setValidator(validator);
bgColorLine->setText(convertQColorToQString(bgColor));
break;
}
case 2 : // dec pallete
{
bgColorLine->hide();
bgRedLabel->show();
bgRedBox->show();
bgGreenLabel->show();
bgGreenBox->show();
bgBlueLabel->show();
bgBlueBox->show();
bgRedBox->setValue(bgColor.red());
bgGreenBox->setValue(bgColor.green());
bgBlueBox->setValue(bgColor.blue());
break;
}
}
}
示例2: validate
QValidator::State cwClinoValidator::validate ( QString & input, int & pos ) const {
if(input.isEmpty()) {
return QValidator::Acceptable;
}
QDoubleValidator doubleValidator;
doubleValidator.setTop(90);
doubleValidator.setBottom(-90);
doubleValidator.setNotation(QDoubleValidator::StandardNotation);
QValidator::State state = doubleValidator.validate(input, pos);
switch(state) {
case QValidator::Invalid: {
QRegExpValidator upDownValidator;
QRegExp regexp("up|down", Qt::CaseInsensitive);
upDownValidator.setRegExp(regexp);
return upDownValidator.validate(input, pos);
}
case QValidator::Acceptable: {
//Just make sure we can convert the input
bool okay;
double value = input.toDouble(&okay);
if(!okay || !check(value)) {
//The validator is dump ... this handle use case input="5,5"
return QValidator::Invalid;
}
break;
}
default:
break;
}
return state;
}
示例3: setRange
//================================================================================
void customLineEdit::setRange(std::string regexp)
{
QRegExp theRegexp(QString(regexp.c_str()));
QRegExpValidator * validator = new QRegExpValidator(this) ;
validator->setRegExp(theRegexp);
this->setValidator(validator) ;
}
示例4: QDialog
TilesOrderDialog::TilesOrderDialog(QWidget* pParent, const std::vector<unsigned int>& state)
: QDialog(pParent, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
setupUi(this);
QString boardStateStr;
for (auto index : state)
{
boardStateStr += QString::number(index) + " ";
}
QRegExpValidator * validator = new QRegExpValidator();
validator->setRegExp(QRegExp(validatorRegExpPattern(state.size())));
lineEditPosition->setValidator(validator);
lineEditPosition->setText(boardStateStr);
connect(buttonCancel, &QPushButton::clicked, this, &TilesOrderDialog::reject);
connect(buttonOk , &QPushButton::clicked, this, &TilesOrderDialog::onOkClick);
if (pParent)
{
move(pParent->frameGeometry().center() - frameGeometry().center());
}
}
示例5: defineEditorAttribute
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCompletions::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{
caf::PdmUiLineEditorAttribute* lineEditorAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>(attribute);
if (field == &m_wellNameForExport && lineEditorAttr)
{
QRegExpValidator* validator = new QRegExpValidator(nullptr);
validator->setRegExp(wellNameForExportRegExp());
lineEditorAttr->validator = validator;
}
else if (field == &m_drainageRadiusForPI && lineEditorAttr)
{
caf::PdmDoubleStringValidator* validator = new caf::PdmDoubleStringValidator("1*");
lineEditorAttr->validator = validator;
}
else if (field == &m_wellBoreFluidPVTTable && lineEditorAttr)
{
// Positive integer
QIntValidator* validator = new QIntValidator(0, std::numeric_limits<int>::max(), nullptr);
lineEditorAttr->validator = validator;
}
else if (field == &m_fluidInPlaceRegion && lineEditorAttr)
{
// Any integer
QIntValidator* validator = new QIntValidator(-std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr);
lineEditorAttr->validator = validator;
}
}
示例6: PreferencePage
DlgImportExportIges::DlgImportExportIges(QWidget* parent)
: PreferencePage(parent)
{
ui = new Ui_DlgImportExportIges();
ui->setupUi(this);
ui->lineEditProduct->setReadOnly(true);
bg = new QButtonGroup(this);
bg->addButton(ui->radioButtonBRepOff, 0);
bg->addButton(ui->radioButtonBRepOn, 1);
QRegExp rx;
rx.setPattern(QString::fromLatin1("[\\x00-\\x7F]+"));
QRegExpValidator* companyValidator = new QRegExpValidator(ui->lineEditCompany);
companyValidator->setRegExp(rx);
ui->lineEditCompany->setValidator(companyValidator);
QRegExpValidator* authorValidator = new QRegExpValidator(ui->lineEditAuthor);
authorValidator->setRegExp(rx);
ui->lineEditAuthor->setValidator(authorValidator);
}
示例7: QDialog
ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigurationDialog),
m_settings(0)
{
ui->setupUi(this);
// Filter out characters which are not allowed in a file name
QRegExpValidator *fileNameValidator = new QRegExpValidator(ui->name);
fileNameValidator->setRegExp(QRegExp(QLatin1String("^[^\\/\\\\\\?\\>\\<\\*\\%\\:\\\"\\']*$")));
ui->name->setValidator(fileNameValidator);
updateDocumentation();
connect(ui->name, SIGNAL(textChanged(QString)), this, SLOT(updateOkButton()));
updateOkButton(); // force initial test.
connect(ui->editor, SIGNAL(documentationChanged(QString,QString)),
this, SLOT(updateDocumentation(QString,QString)));
// Set palette and font according to settings
const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::instance()->fontSettings();
const QTextCharFormat tf = fs.toTextCharFormat(TextEditor::C_TEXT);
const QTextCharFormat selectionFormat = fs.toTextCharFormat(TextEditor::C_SELECTION);
QPalette pal;
pal.setColor(QPalette::Base, tf.background().color());
pal.setColor(QPalette::Text, tf.foreground().color());
pal.setColor(QPalette::Foreground, tf.foreground().color());
if (selectionFormat.background().style() != Qt::NoBrush)
pal.setColor(QPalette::Highlight, selectionFormat.background().color());
pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
ui->documentation->setPalette(pal);
ui->editor->setPalette(pal);
ui->documentation->setFont(tf.font());
ui->editor->setFont(tf.font());
// Set style sheet for documentation browser
const QTextCharFormat tfOption = fs.toTextCharFormat(TextEditor::C_FIELD);
const QTextCharFormat tfParam = fs.toTextCharFormat(TextEditor::C_STRING);
const QString css = QString::fromLatin1("span.param {color: %1; background-color: %2;} "
"span.option {color: %3; background-color: %4;} "
"p { text-align: justify; } ")
.arg(tfParam.foreground().color().name())
.arg(tfParam.background().style() == Qt::NoBrush
? QString() : tfParam.background().color().name())
.arg(tfOption.foreground().color().name())
.arg(tfOption.background().style() == Qt::NoBrush
? QString() : tfOption.background().color().name())
;
ui->documentation->document()->setDefaultStyleSheet(css);
}
示例8: rx
frmConnect::frmConnect(QWidget *parent) :
QWidget(parent),
ui(new Ui::frmConnect)
{
ui->setupUi(this);
moveWindowToCenter();
//маска для IP
QRegExpValidator *v = new QRegExpValidator(this);
QRegExp rx("((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})");
v->setRegExp(rx);
ui->txtServer->setValidator(v);
ui->txtPort->setValidator(new QIntValidator(0,65536,ui->txtPort));
}
示例9: createEditor
QWidget* TileTexturePreviewWidgetItemDelegate::createEditor(QWidget* parent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
QWidget* widget = QItemDelegate::createEditor(parent, option, index);
QLineEdit* edit = qobject_cast<QLineEdit*>(widget);
if (edit != 0)
{
QRegExpValidator* validator = new QRegExpValidator();
validator->setRegExp(QRegExp(TILE_COLOR_VALIDATE_REGEXP, Qt::CaseInsensitive));
edit->setValidator(validator);
}
return widget;
}
示例10: userNameReg
LoginWidget::LoginWidget(QWidget *parent) : QWidget(parent)
{
QGridLayout* mainLayout = new QGridLayout(this);
this->setLayout(mainLayout);
ipEdit = new QLineEdit();
ipEdit->setInputMask("000.000.000.000;_");
loginEdit = new QLineEdit();
loginEdit->setMaxLength(25);
passwordEdit = new QLineEdit();
passwordEdit->setEchoMode(QLineEdit::Password);
passwordEdit->setMaxLength(25);
mainLayout->addWidget(new QLabel("IP адрес: "), 0, 0);
mainLayout->addWidget(new QLabel("Логин: "), 1, 0);
mainLayout->addWidget(new QLabel("Пароль: "), 2, 0);
mainLayout->addWidget(ipEdit, 0, 1);
mainLayout->addWidget(loginEdit, 1, 1);
mainLayout->addWidget(passwordEdit, 2, 1);
QHBoxLayout* buttonLayout = new QHBoxLayout();
mainLayout->addLayout(buttonLayout, 3, 1);
goLogin = new QPushButton("Вход");
goExit = new QPushButton("Выход");
buttonLayout->addWidget(goLogin);
buttonLayout->addWidget(goExit);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint);
QRegExpValidator* userNameValid = new QRegExpValidator();
QRegExp userNameReg("[A-Za-z0-9_]+$");
userNameValid->setRegExp(userNameReg);
loginEdit->setValidator(userNameValid);
connect(goLogin,SIGNAL(clicked(bool)),this,SLOT(onGoLogin()));
connect(goExit,SIGNAL(clicked(bool)),this,SLOT(onGoExit()));
}
示例11: CreateQtPartControl
void QmitkIGTLDeviceSetupConnectionWidget::CreateQtPartControl(QWidget *parent)
{
if (!m_Controls)
{
// create GUI widgets
m_Controls = new Ui::QmitkIGTLDeviceSetupConnectionWidgetControls;
// setup GUI widgets
m_Controls->setupUi(parent);
}
// set the validator for the ip edit box (values must be between 0 and 255 and
// there are four of them, seperated with a point
QRegExpValidator *v = new QRegExpValidator(this);
QRegExp rx("((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})");
v->setRegExp(rx);
m_Controls->editIP->setValidator(v);
// set the validator for the port edit box (values must be between 1 and 65535)
m_Controls->editPort->setValidator(new QIntValidator(1, 65535, this));
//connect slots with signals
CreateConnections();
}
示例12: slotApplyCompText
// -----------------------------------------------------------
// Is called if user clicked on component text of if return is
// pressed in the component text QLineEdit.
// In "view->MAx3" is the number of the current property.
void QucsApp::slotApplyCompText()
{
QString s;
QFont f = QucsSettings.font;
Schematic *Doc = (Schematic*)DocumentTab->currentPage();
f.setPointSizeFloat( Doc->Scale * float(f.pointSize()) );
editText->setFont(f);
Property *pp = 0;
Component *pc = (Component*)view->focusElement;
if(!pc) return; // should never happen
view->MAx1 = pc->cx + pc->tx;
view->MAy1 = pc->cy + pc->ty;
int z, n=0; // "n" is number of property on screen
pp = pc->Props.first();
for(z=view->MAx3; z>0; z--) { // calculate "n"
if(!pp) { // should never happen
editText->setHidden(true);
return;
}
if(pp->display) n++; // is visible ?
pp = pc->Props.next();
}
pp = 0;
if(view->MAx3 > 0) pp = pc->Props.at(view->MAx3-1); // current property
else s = pc->Name;
if(!editText->isHidden()) { // is called the first time ?
// no -> apply value to current property
if(view->MAx3 == 0) { // component name ?
Component *pc2;
if(!editText->text().isEmpty())
if(pc->Name != editText->text()) {
for(pc2 = Doc->Components->first(); pc2!=0; pc2 = Doc->Components->next())
if(pc2->Name == editText->text())
break; // found component with the same name ?
if(!pc2) {
pc->Name = editText->text();
Doc->setChanged(true, true); // only one undo state
}
}
}
else if(pp) { // property was applied
if(pp->Value != editText->text()) {
pp->Value = editText->text();
Doc->recreateComponent(pc); // because of "Num" and schematic symbol
Doc->setChanged(true, true); // only one undo state
}
}
n++; // next row on screen
(view->MAx3)++; // next property
pp = pc->Props.at(view->MAx3-1); // search for next property
Doc->viewport()->update();
view->drawn = false;
if(!pp) { // was already last property ?
editText->setHidden(true);
return;
}
while(!pp->display) { // search for next visible property
(view->MAx3)++; // next property
pp = pc->Props.next();
if(!pp) { // was already last property ?
editText->setHidden(true);
return;
}
}
}
// avoid seeing the property text behind the line edit
if(pp) // Is it first property or component name ?
s = pp->Value;
editText->setMinimumWidth(editText->fontMetrics().width(s)+4);
Doc->contentsToViewport(int(Doc->Scale * float(view->MAx1 - Doc->ViewX1)),
int(Doc->Scale * float(view->MAy1 - Doc->ViewY1)),
view->MAx2, view->MAy2);
editText->setReadOnly(false);
if(pp) { // is it a property ?
s = pp->Value;
view->MAx2 += editText->fontMetrics().width(pp->Name+"=");
if(pp->Description.find('[') >= 0) // is selection list ?
editText->setReadOnly(true);
Expr_CompProp.setPattern("[^\"]*");
if(!pc->showName) n--;
}
else // it is the component name
Expr_CompProp.setPattern("[\\w_]+");
Val_CompProp.setRegExp(Expr_CompProp);
//.........这里部分代码省略.........