PDA

View Full Version : need help in QThread()



wagmare
18th December 2008, 11:01
hi friend,
i request you one help ... i need some good example programs which uses QThread() ... small program is enough because i rode your threads about QThread and i am now practicing some codes in QThread but i am unable to learn completely within threadfortuneserver example ..
please send me any program ... how signal slot is working between the process and another thread ... small program rather than network socket program like doing inside widgets ...
please help me

jpn
18th December 2008, 12:24
Fortune server is a networking example. What about the actual threading examples, have you checked them? Did you search the forum for QThread?

wagmare
18th December 2008, 13:11
thanks for reply

i need some code to work on the gui part ..
ex:
if the user clicks a button the text of the QLable should change its text which i should run that slot for changing text in another parallel thread so i am searching something which run timely changing the GUI appearance ...

i searched for that in this forum but cant get any example like that ...because i am new to Qt field
i went through fortuneserver but its not updates or repaints the widgets so only i ask for experts

please help me .. just send me any suitable link :)

jpn
18th December 2008, 13:21
i need some code to work on the gui part ..
Ok, before we start. Do NOT touch GUI in a worker thread. From Qt docs: "Although QObject is reentrant, the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread."

You can do some expensive calculation in worker threads, but you must deliver the results to the GUI thread where you can change the GUI to reflect the results. You can use signals and slots or custom events to deliver calculated results to the main GUI thread. Or perhaps you could even use the higher level threading API of Qt Concurrent.