PDA

View Full Version : Inserting Item to a QTreeWidget from Thread?



vishal.chauhan
22nd June 2007, 07:16
Hi All,

I m using Qt 4.1.5 on my MAC.
I have a QTreeWidget in which I want to Insert Item at run time from the Thread.I m calling the function in which I have Insert the Item in the Other Class.

Actually It is calling the function but could not Insert the Item in the QTreeWidget.

If anybody knows the Issue then plz help me.

Thanks.

guilugi
22nd June 2007, 08:56
You can't call GUI-methods from another thread but the main thread !

If you want to do so, just emit a signal from your secondary thread, and connect it to an "addItem" slot in your TreeWidget class.

Guilugi.

marcel
22nd June 2007, 18:23
You can't call GUI-methods from another thread but the main thread !

Generally you can call GUI thread methods from worker threads, but extra care must be taken.
You can't do things that affect in any way the event loop of the main thread. Like drawing on a widget whose paint event is in progress, etc.

Regards

guilugi
23rd June 2007, 11:23
Yup marcel, thanks for clarifying this :)
That's what I meant !