Archived:How to restrict input to a QLineEdit using a validator
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (using C++ for the Qt app UI) is deprecated.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (using C++ for the Qt app UI) is deprecated.
This code snippet how to use validation filter to restrict the input into a QLineEdit using a "validator". There are a number of different validation filters including QIntValidator, QDoubleValidator, QRegExpValidator, and you can create your own as well.
Article Metadata
Tested with
Devices(s): Emulator / desktop / device
Compatibility
Platform(s): All Qt Supported
Article
Keywords: QLineEdit
Created: skumar_rao
(25 Nov 2010)
Last edited: hamishwillee
(11 Oct 2012)
QLineEdit *le = new QLineEdit(this);
le->setValidator(new QIntValidator(this));


(no comments yet)