[Qt-interest] Struggling with QLineEdit / QValidator behaviour
Florian Delizy
florian.delizy at gmail.com
Sat Jun 19 04:35:15 CEST 2010
Hi,
I am trying to implement a simple QLineEdit that is blinking red when the
user is entering a wrong input. I got the blinking part right, but it gets
tricky when I actually want the text to be validated *only* when the user
hit Enter/Return. I use that QLineEdit as a Editor inside a TableView widget
(I wrote my own delegate and surcharged createEditor() ).
I tried the following :
- Implement my own QValidator => fail QLineEdit is calling validate() every
single keypress, and I have no way to know if that press was the last one
- Re-implement the keyPressEvent / keyReleaseEvent to catch
Key_Return/Key_Enter missed, for some reason, the key is catched in another
place, and the editor gets discarded before I have a chance to make it
blink.
- Install the validator only after I detect the Key_Return/Key_Enter
keyPressEvent on the editor, missed again, the key is catched in another
place, editor gets discarded validate() is not even called (duh!)
I tried to surcharg keyPressEvent in the TableView as well, but it gets
caught somewhere else (duh !!)
well, I still have the option to re-invent the wheel and implement my full
grown CustomLineEdit from scracth, (including all the existing features of
the QLineEdit) but I think this is quite overkill.
Could somebody point me to the
magicMethodAllowingValidatorToBeCalledOnlyAtInputEnd() ? or something that
would give me some hint on how to achieve that behaviour ?
my next step is to read the code of QLineEdit itself I guess to see if there
are some hidden hooks :(
Thanks,
--
Florian Delizy
BTW: I did read QLineEdit/QWidget/QStyledItemDelegate/QTableView assistant
page, a lot of time :/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100619/b3902149/attachment.html
More information about the Qt-interest-old
mailing list