PDA

View Full Version : Problem updating Line edit from a thread



raghvendramisra
27th November 2007, 06:16
I have a QT application in which i am calling a thread .
In the thread i am calling a function to update a lineEdit box dynamically based on certain conditions.

But the problem is that when i run the application for some time , it hangs showing error "xlib: unexpected async reply (sequence.......).

I searched for this error and found that i cannot update GUI from a thread.

But my application needs a thread and gui to be updated dynamically.

How can i do this.
???????

Regards

Raghvendra

ChristianEhrlicher
27th November 2007, 07:57
You can't update any gui element from outside the main-thread. You have to change your code to do updates only in mainthread (e.g. by using signals/slots to carry the data to the mainthread).

raghvendramisra
27th November 2007, 08:45
actually i am new to qt.
by main thread do you mean that i should call the function in the main program i.e from where i am calling the thread?


Plz let me know

Regards

Raghvendra

DeepDiver
27th November 2007, 08:51
Have a look at this:
http://doc.trolltech.com/4.3/threads-mandelbrot.html

jpn
27th November 2007, 10:26
Signals and slots are not thread-safe in Qt 3. Use custom events to deliver data to main GUI thread. See Thread-safe Event Posting (http://doc.trolltech.com/3.3/threads.html#5).

raghvendramisra
3rd December 2007, 06:05
Thanks very much


i have used the customevent and my problem is now solved:)