[Qt-interest] Struggling with QLineEdit / QValidator behaviour

Florian Delizy florian.delizy at gmail.com
Sat Jun 19 09:49:49 CEST 2010


I don't need the validator but when i do that as i say the linedit  
disappear ... I ha e no way to prevent the tableview (or the  
delegate ?) from discarding the editor

I tried to surcharge pretty much all the related delegate methods but  
found nothing

Once the return key is pressed the editor (in that case the lineedit)  
is discarded

Envoyé de mon iPhone

Le 19 juin 2010 à 15:06, Chris Wilson <christopher.g.wilson at gmail.com>  
a écrit :

> Just a thought: Do you have to have a validator on the line edit?  
> Otherwise, you can just connect to the returnPressed() or the  
> editingFinished() signals. (though these only work if the validator  
> is returning acceptable)
>
> http://doc.qt.nokia.com/4.6/qlineedit.html#returnPressed
> http://doc.qt.nokia.com/4.6/qlineedit.html#editingFinished
>
> On Fri, Jun 18, 2010 at 9:35 PM, Florian Delizy <florian.delizy at gmail.com 
> > wrote:
> 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 :/
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100619/872ec0df/attachment.html 


More information about the Qt-interest-old mailing list