PDA

View Full Version : Need a thread or not



avis_phoenix
14th August 2008, 22:46
Hi everybody :)

Well, I need some help to decide,if to use or not, threads.

I am using QGraphicsView to draw figures, and I have a function that changes the figure, but this function is very slow. I need to be able to pause it,stop it,and restart it at any time. This function is part to the gui with information of the process and buttons to pause,stop and restart.

As code is now; The information window is drawn until the process finishes, while the main window and the information window frezze. Maybe what is needed is a thread.

Please somebody help me
Thanks

The Storm
14th August 2008, 22:48
You can make the calculations in other thread and then via signal/slots to draw it directly on the GUI. :)

kghose
14th August 2008, 23:00
Hi everybody :)

Well, I need some help to decide,if to use or not, threads.

I am using QGraphicsView to draw figures, and I have a function that changes the figure, but this function is very slow. I need to be able to pause it,stop it,and restart it at any time. This function is part to the gui with information of the process and buttons to pause,stop and restart.

So what is the code; The information window is drawn until the process finishes, while the main window and the information window frezze. Maybe what is needed is a thread.

Please somebody help me
Thanks

The mandelbrot example (http://doc.trolltech.com/4.3/threads-mandelbrot.html) in the documentation was particularly useful for me on this topic -K

wysota
14th August 2008, 23:46
If your calculation is iteration based or consists of some steps then you don't need a separate thread. Signals and slots and probably QTime and QTimer inside one thread will be sufficient.