PDA

View Full Version : Problem with receiving events from QDateEdit



gunhelstr
20th April 2006, 08:58
I have a problem with QDateEdit. I want to snap its contents when it looses focus. Since QDateEdit has got only one signal,

void valueChanged ( const QDate & date ) wich is not very usefull for my purpose


I have tried to reimplement bool FD_KoderWidget::eventFilter( QObject *obj, QEvent *ev )

Inside eventFilter, I do my work if ev is a QEvent::FocusOut, and obj is my QDateEdit
otherwise I just pass the event on to QWidget::eventFilter(....)

The problem seems to be that QDateEdit never produces an event.
After a lot of thinking and various modifications of my code, I tried to simply replace QDateEdit with a QLineEdit . Then my code worked perfectly well.

What could be the problem with QDateEdit?

wysota
20th April 2006, 09:01
Did you install the filter? It's not enough to just reimplement eventFilter. You can do that with event() but using eventFilter() involves the need to call installEventFilter() first. If you are subclassing QDateEdit, it might be better to simply reimplement appropriate event handler.

gunhelstr
20th April 2006, 10:46
I did install the filter, and I am not subclassing QDateEdit.

So the problem must be something else.:)

jpn
20th April 2006, 10:58
Try installing the event filter for date edit's children and see if any of them receives the focus out event.
Something like:


foreach (QObject* child, dateEdit->children())
child->installEventFilter(eventFilter);

gunhelstr
20th April 2006, 11:21
Thanks for your help.

I found the problem. I ran uic on the form from DOS. And I think .NET did not realize that a new object-file was needed.
I deleted the object-file to force the compiler to generate a new, and then my code worked.:)