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. QLineEdit::setValidator(const QValidator*) validates the QLineEdit::displayText() not QLineEdit::text()
Forum Updated to NodeBB v4.3 + New Features

QLineEdit::setValidator(const QValidator*) validates the QLineEdit::displayText() not QLineEdit::text()

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.8k 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.
  • napajejenunedk0N Offline
    napajejenunedk0N Offline
    napajejenunedk0
    wrote on last edited by
    #1

    Let's say you want to create a QLineEdit that allows the user to enter an IPv4/6 address.

    @
    ...

    QLineEdit* ipAddressEditor = new QLineEdit;
    ipAddressEditor->setInputMask( "000.000.000.000;_" ); // IP address; blanks are _ - the example is taken from Qt library 4.8's "QLineEdit documentation":http://qt-project.org/doc/qt-4.8/qlineedit.html#inputMask-prop
    ipAddressEditor->setValidator(new IpAddressValidator( ipAddressEditor ) );

    ...

    class IpAddressValidator : public QValidator
    {
    Q_OBJECT
    public:
    explicit IpAddressValidator( QObject* parent = 0 );

    virtual State validate( QString& input, int& pos ) const { ... }
    

    };

    ...
    @

    The input mask "000.000.000.000;_" is taken from Qt library 4.8's "QLineEdit documentation":http://qt-project.org/doc/qt-4.8/qlineedit.html#inputMask-prop.

    QLineEdit gives its displayText member function value ("127.__0.__0.__1" for instance) as input parameter to the IpAddressValidator instead of the value of its text member function ("127.0.0.1").

    The question:

    Shouldn't there be another property of QLineEdit that allows the client of QLineEdit to explicitly specify which property - displayText or text should be taken in consideration by the validator?

    Should a feature request/bug report be filed for this case?

    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