Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QRegExp not Accepting Modifier Values ?
Forum Updated to NodeBB v4.3 + New Features

QRegExp not Accepting Modifier Values ?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 943 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Macro
    wrote on last edited by
    #1

    Hi...

    I have a QLineEdit and a QStringList. My String List contains “m/s^2”, “m/min^2”, “m/s^3”, “m/min^3” strings in it (^ denotes the Power of value). My Line Edit should accept only the characters which are present in the StringList.. I solved that and it Works Fine.

    Now, the Problem is, My RegExp is Not Accepting the ^[SHIFT + 6 key]. I cannot enter that power symbol in my QLineEdit. Other characters like "m", "/" are working Fine... Can u plz Suggest me Why this QRegExp not Accepting the Modifier Values?

    Here's my Code:

    @QString regExpression = "(";
    for (int i = 0; i < getStringList()->size(); ++i)
    {
    regExpression.append(getStringList()->at(i) + "|");
    }

    QRegExp rE(regExpression);
    q_LineEdit->setValidator(new QRegExpValidator(rE, this));@

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      replace the last character of the regExpression with ). your currently is | which makes the regexp invalid. you should check the validity of the regexp with rE.isValid(); next time. also for your ^ you should put it in the string like this: "\^" because the ^ sign is interpreted by the QRegExp.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved