[Qt-interest] Problems using postEvent ..plz help

Arnold Krille arnold at arnoldarts.de
Sat Jan 10 21:33:36 CET 2009


On Saturday 10 January 2009 18:03:13 Neeraj Jhawar wrote:
> I tried to implement the postEvent but this code is just not working.
> Can any of you please help with the code...
> I am trying to accomplish : Take a number from the thread via
> postEvent and display is in the
> textedit box every 1ms.
> There are 3 files
> 1. main.cpp
> 2.postevent.h
> 3. postevent.cpp

Would have been better to attach the files to the mail instead of posting them 
directly...

Anyway, you define temp_c and use it, but it never get allocated some memory as 
far as I see it. You will get segmentation faults with that. And why are you 
converting the temporary float to a char* when all you want to do is convert it 
to a QString? Why not let QString handle the float directly?

Please follow the warnings displayed by gcc and include iostream instead of 
iostream.h! Thats how it is done with standard C++...

And I hope the @@@ are only to show the lines with the error...

Now for the error:

> ****************************THE ERROR MESSAGE******************************
> postevent.cpp: In member function `virtual void ProdThread::run()':
> postevent.cpp:42: parse error before `,' token
> postevent.cpp:41: warning: unused variable `ProdEvent*pe'

You try to send and event to ThreadForm. But what is ThreadForm??? postEvent 
is expecting a pointer to an QObject, you are trying to feed it a class-name. 
Which is not even possible in C++, so the compiler bails out...
Either your sending thread has to have a signal (oops, only possible in 
Qt4;-), or it has to know the receiving object (which only needs to be a 
QObject).

Please, please, please do yourself (and us!) a favour and switch to Qt4!

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090110/058df361/attachment.bin 


More information about the Qt-interest-old mailing list