[Qt-interest] cannot send posted events for objects in another thread

Yifei Li yifli at mtu.edu
Wed Apr 15 00:57:09 CEST 2009


Marco,

Thank you for the reply.  I actually tried several workarounds.

One of them is to pass a pointer of QProgressDialog to WorkerThread. And 
remit the signals from Foo in WorkerThread like this:
connect( &foo, SIGNAL(currentStep()), this,  SIGNAL(currentStep()) );

Then in the main thread:
connect(  &worker_thread, SIGNAL(currentStep()),   p_progressDlg,  
SLOT(updateProgress()));

Even this gave me the same error:

QCoreApplication::sendPostedEvents: Cannot send posted events for 
objects in another thread


Any ideas?

Yifei


Marco Borm wrote:
> http://doc.trolltech.com/4.5/threads.html
> "In GUI applications, the main thread is also called the GUI thread 
> because it's the only thread that is allowed to perform GUI-related 
> operations."
>
> So calling show() in the run-function of the thread isn't allowed.
>
> Marco
>
> Yifei Li wrote:
>   
>> Hi all,
>>
>> [...]
>> I have a global object of Foo  and all the work is done in Foo:doWork, 
>> Foo has a signal telling us its progress.  Then in WorkerThread::run(),  
>> Foo::doWork is called.  I connet Foo's signal to a slot in WorkerThread, 
>> and in the slot I updated the value of a progress dialog.
>>
>> [...]
>>
>> QCoreApplication::sendPostedEvents: Cannot send posted events for 
>> objects in another thread
>> ( the above message is repeated here)
>> MyApp: xcb_lock.c:77: _XGetXCBBuffer: Assertion `((int) ((xcb_req) - 
>> (dpy->request)) >= 0)' failed.
>>
>> [...]
>> void WorkerThread::run()
>> {
>>     pd->show();
>>     foo.doWork();      // do the work
>> }
>>
>>   
>>     
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   




More information about the Qt-interest-old mailing list