QLineEdit::setValidator(const QValidator*) validates the QLineEdit::displayText() not QLineEdit::text()
-
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?