Qt-interest Archive, May 2007
Re: customEvent problems
Message 1 in thread
Hi,
I'm having problems using the virtual method
QObject::customEvent(Qevent *); it doesn't seem to get called when I
send an Event of type "QEvent::User+1" from a class inheriting QThread
to a class inheriting from QObject.
I've posted a very short example of this here:
http://orbit.psi.edu/~tricaric/tmp/events1.0.0.tar.gz
If you compile and run it, you'll see that the events are generated
and sent by the Sender thread to the Receiver class, but they never
seem to be received.
Any help on getting the Receiver class working correctly will be
greatly appreciated.
Thanks,
Pasquale
--
[ signature omitted ]
Message 2 in thread
On 15.05.07 16:49:35, Pasquale Tricarico wrote:
> Hi,
>
> I'm having problems using the virtual method
> QObject::customEvent(Qevent *); it doesn't seem to get called when I
> send an Event of type "QEvent::User+1" from a class inheriting QThread
> to a class inheriting from QObject.
>
> I've posted a very short example of this here:
>
> http://orbit.psi.edu/~tricaric/tmp/events1.0.0.tar.gz
I guess you're porting a Qt3 app right? Because the example uses Qt4
headers, but in Qt4 customEvent takes a QCustomEvent pointer, not
QEvent. See api documentation ;)
Andreas
--
[ signature omitted ]
Message 3 in thread
On 5/15/07, Andreas Pakulat <apaku@xxxxxx> wrote:
> I guess you're porting a Qt3 app right? Because the example uses Qt4
> headers, but in Qt4 customEvent takes a QCustomEvent pointer, not
> QEvent. See api documentation ;)
That's not true:
http://doc.trolltech.com/4.2/qcustomevent.html
I'm using plain Qt4 code, not porting old code.
Thanks,
Pasquale
--
[ signature omitted ]
Message 4 in thread
On 15.05.07 17:37:57, Pasquale Tricarico wrote:
> On 5/15/07, Andreas Pakulat <apaku@xxxxxx> wrote:
> >I guess you're porting a Qt3 app right? Because the example uses Qt4
> >headers, but in Qt4 customEvent takes a QCustomEvent pointer, not
> >QEvent. See api documentation ;)
>
> That's not true:
>
> http://doc.trolltech.com/4.2/qcustomevent.html
>
> I'm using plain Qt4 code, not porting old code.
right, its the other way around, sorry for the confusion.
The solution to your problem is however still in the documentation ;)
You don't create a QApplication or QCoreApplication and thus the main
event loop is not running. Thats the reason your qObject doesn't get any
events. Adding
QCoreApplication app(argc,argv);
app.exec();
right after the s->start() makes the whole thing work here.
Andreas
--
[ signature omitted ]
Message 5 in thread
Great, thank you!
Pasquale
On 5/15/07, Andreas Pakulat <apaku@xxxxxx> wrote:
> On 15.05.07 17:37:57, Pasquale Tricarico wrote:
> > On 5/15/07, Andreas Pakulat <apaku@xxxxxx> wrote:
> > >I guess you're porting a Qt3 app right? Because the example uses Qt4
> > >headers, but in Qt4 customEvent takes a QCustomEvent pointer, not
> > >QEvent. See api documentation ;)
> >
> > That's not true:
> >
> > http://doc.trolltech.com/4.2/qcustomevent.html
> >
> > I'm using plain Qt4 code, not porting old code.
>
> right, its the other way around, sorry for the confusion.
>
> The solution to your problem is however still in the documentation ;)
> You don't create a QApplication or QCoreApplication and thus the main
> event loop is not running. Thats the reason your qObject doesn't get any
> events. Adding
>
> QCoreApplication app(argc,argv);
> app.exec();
>
> right after the s->start() makes the whole thing work here.
>
> Andreas
>
> --
> If your life was a horse, you'd have to shoot it.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
--
[ signature omitted ]