PDA

View Full Version : Performance Issue



linuxdev
10th December 2008, 15:34
Hi,

I have developed an application in Qt, all drawing is perfomed using QPainter.
Application receives data from a socket and draw objects on the display, i also have a background Pixmap to display.
The application is not responding when its loaded moderately i.e. display freezes.

I have one class inherited from QWidget, which does all the drawing,
can i make it as a Thread, by inheriting from QThread and call just painter->update(), function in that?
Making all drawing as a seperate thread....so that performance is increased. :confused:

Or is it much better to redesign my application using Graphics View.(I have not used Graphics View till now, so not very confident about it).

Kindly looking forward to response....:)

caduel
10th December 2008, 16:00
You may not access widgets (or QPixmap from any thread but the "gui thread"), i.e. the drawing has to be done in the main thread.

You may, however, separate network communication, processing of the received packages in separate threads.

Another point is that more than about 20 or 25 repaints per second will keep the cpu busy, but will not help the user too much.
If you have more than 20 repaints per second, just update the internal data (w/o a repaint) and do periodic repaints (of this data) with a QTimer.
If you access this data from multiple threads, you have to protect it with a mutex.

HTH