当前位置: 首页>>代码示例>>C++>>正文


C++ QRegExpValidator类代码示例

本文整理汇总了C++中QRegExpValidator的典型用法代码示例。如果您正苦于以下问题:C++ QRegExpValidator类的具体用法?C++ QRegExpValidator怎么用?C++ QRegExpValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QRegExpValidator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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());
	}
}
开发者ID:Nikitaterm,项目名称:rdo_studio,代码行数:25,代码来源:plugin_game5_tiles_order_dialog.cpp

示例2: switch

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;
}
开发者ID:Cavewhere,项目名称:cavewhere,代码行数:34,代码来源:cwClinoValidator.cpp

示例3: QRegExpValidator

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;

    }
}
开发者ID:OPM,项目名称:ResInsight,代码行数:33,代码来源:RimWellPathCompletions.cpp

示例4: theRegexp

//================================================================================
void customLineEdit::setRange(std::string regexp)
{
  QRegExp theRegexp(QString(regexp.c_str()));
  QRegExpValidator * validator = new QRegExpValidator(this) ;
  validator->setRegExp(theRegexp);
  this->setValidator(validator) ;
}
开发者ID:sakamoto-poteko,项目名称:Monicelli,代码行数:8,代码来源:customLineEdit.cpp

示例5: 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);
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:52,代码来源:configurationdialog.cpp

示例6: QRegExpValidator

// 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;
    }
    }

}
开发者ID:raandoom,项目名称:N900-bootlogo-changer,代码行数:52,代码来源:mainwindow.cpp

示例7: sipIsDerived

static PyObject *meth_QRegExpValidator_validate(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = NULL;
    bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf));

    if (sipIsAPIEnabled(sipName_QString, 2, 0))
    {
        QString * a0;
        int a0State = 0;
        int a1;
        QRegExpValidator *sipCpp;

        static const char *sipKwdList[] = {
            sipName_input,
            sipName_pos,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "BJ1i", &sipSelf, sipType_QRegExpValidator, &sipCpp, sipType_QString,&a0, &a0State, &a1))
        {
            QValidator::State sipRes;
            PyObject *sipResult;

            Py_BEGIN_ALLOW_THREADS
            sipRes = (sipSelfWasArg ? sipCpp->QRegExpValidator::validate(*a0,a1) : sipCpp->validate(*a0,a1));
            Py_END_ALLOW_THREADS

            sipResult = sipBuildResult(0,"(FDi)",sipRes,sipType_QValidator_State,a0,sipType_QString,NULL,a1);
            sipReleaseType(a0,sipType_QString,a0State);

            return sipResult;
        }
    }

    if (sipIsAPIEnabled(sipName_QString, 0, 2))
    {
        QString * a0;
        int a1;
        QRegExpValidator *sipCpp;

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, NULL, NULL, "BJ9i", &sipSelf, sipType_QRegExpValidator, &sipCpp, sipType_QString,&a0, &a1))
        {
            QValidator::State sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = (sipSelfWasArg ? sipCpp->QRegExpValidator::validate(*a0,a1) : sipCpp->validate(*a0,a1));
            Py_END_ALLOW_THREADS

            return sipBuildResult(0,"(Fi)",sipRes,sipType_QValidator_State,a1);
        }
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:49,代码来源:sipQtGuiQRegExpValidator.cpp

示例8: QWidget

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));
}
开发者ID:Kolizej,项目名称:LessonControl,代码行数:15,代码来源:frmconnect.cpp

示例9: QRegExpValidator

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;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:16,代码来源:TileTexturePreviewWidgetItemDelegate.cpp

示例10: QWidget

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()));
}
开发者ID:Shikyaro,项目名称:uStorage,代码行数:45,代码来源:loginwidget.cpp

示例11: 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);
}
开发者ID:frankhardy,项目名称:FreeCAD,代码行数:20,代码来源:DlgSettingsGeneral.cpp

示例12: QRegExpValidator

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();
}
开发者ID:DiagnosisMultisystems,项目名称:MITK,代码行数:22,代码来源:QmitkIGTLDeviceSetupConnectionWidget.cpp

示例13: QDialog

EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EEPROMWindow)
{
    ui->setupUi(this);

    QSettings settings;
    firmware = settings.value("printer/firmware").toInt();

    QLayout *layout = new QVBoxLayout();

    if(firmware == Repetier)
    {
        int j = 0;
        foreach (QString str, eepromLines)
        {
            str.remove("EPR:"); // Clear the unneeded part

            repetierEEPROMline currentLine; //Storage for EEPROM values

            QStringList tmp = str.split(' ');

            currentLine.T = tmp.at(0).toInt();
            currentLine.P = tmp.at(1).toInt();
            currentLine.S = tmp.at(2);

            lines.append(currentLine);

            QString msg;
            for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " "); //Rejoin the rest

            QLayout *line = new QGridLayout();

            QLabel *label = new QLabel(msg, this);
            QLineEdit *edit = new QLineEdit(currentLine.S,this);

            QFrame* hline = new QFrame();
            hline->setFrameShape(QFrame::HLine);
            hline->setFrameShadow(QFrame::Sunken);
            line->addWidget(hline);

            edit->setObjectName("e"+QString::number(j)); //Name the LineEdit, so when it emits signal we know where it came from

            QRegExpValidator *doublevalidator = new QRegExpValidator(
                                                    QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$",
                                                    Qt::CaseInsensitive), this);
            doublevalidator->setLocale(QLocale::English);

            switch(currentLine.T) // set right validator for the line
            {
            case 0:
                edit->setValidator(new QIntValidator(-128, 255, this));
            case 1:
            case 2:
                edit->setValidator(new QIntValidator(this));
                break;
            case 3:
                edit->setValidator(doublevalidator);
                break;
            default:
                break;
            }

            connect(edit, &QLineEdit::textChanged, this, &EEPROMWindow::lineChanged);

            line->addWidget(label);
            line->addWidget(edit);

            line->setMargin(2);

            layout->addItem(line);

            j++; // increase counter
        }
开发者ID:youdemo,项目名称:RepRaptor,代码行数:74,代码来源:eepromwindow.cpp

示例14: 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);
//.........这里部分代码省略.........
开发者ID:MikeBrinson,项目名称:qucs,代码行数:101,代码来源:qucs_actions.cpp


注:本文中的QRegExpValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。