开发者

Qt4 child thread edit Gui on mainthread

开发者 https://www.devze.com 2023-04-07 23:19 出处:网络
I have a tablewidget which needs to be appen开发者_Go百科ded with data from a child thread. I get this error It is not safe to use pixmaps outside the GUI thread. In c# I used a Disptacher to tell th

I have a tablewidget which needs to be appen开发者_Go百科ded with data from a child thread.

I get this error It is not safe to use pixmaps outside the GUI thread. In c# I used a Disptacher to tell the mainThread to append data in a gui object.

I assume there is some how something close to this? Am using qt4.7 I have made a slot in the parent and a signal within the thread object.. an emit signal from the child thread to send a signal to a slot in the parent. but the signal is not firing. when i execute the method like so object->run(); (i.e from mainthread) it works fine.. but when i execute it from the thread object->start(); the signal is not fired.. i neeed to do somework with a thread not in mainthread..

UPDATE--27/09 i just got to the root of the problem.. the signal and slot are working but the child thread is lauching a qnetworkaccessmanger object that is causing all this trouble.. i commented the networkaccess object and no error.. I need the thread to call a network request.. and update the results in the gui..


The easiest way is to use Qt's signal/slot mechanism with a connection type of Qt::QueuedConnection. This queues the call to the slot in the thread the receiver object lives in automatically.

0

精彩评论

暂无评论...
验证码 换一张
取 消