PDA

View Full Version : QGraphicsTextItem speed up creation/rendering process



MForceOne
11th March 2010, 19:30
Hi,
I want to use QGraphicsTextItem and want to speed up the creation/rendering process in order not to slow down the GUI as much as possible.
So I am wondering if it is possible to create QTextDocument in a separate thread. This will get the expensive layout operations off the GUI thread. Once QTextDocument is created I was thinking to set it on the QGraphicsTextItem.

Does anyone have some ideas if that is the right way or how I can achieve to have the rendering for QGraphicsTextItem in a separate thread?

Thanks for your help.

M.

wysota
11th March 2010, 20:07
I don't think this would work. What do you have in your text item that needs so intensive rendering?

MForceOne
11th March 2010, 20:18
Can you think of any way how to prevent to slow down the GUI thread when I want to create/render QGraphicsTextItem ?

wysota
11th March 2010, 20:55
I can think of many ways to speed up the process but what fits best really depends on what your code does. For example creating the items and adding them to a scene before setting a scene on the view will be faster than setting the scene on the view first and adding items later. You can also add items in bundles (not all at once) allowing the event loop to process pending events in the meantime. There are other things too but without knowing your exact situation it's not possible to suggest anything. And by the way - moving the process to another thread wouldn't help in any way, you'd still have some loop in the GUI that would block event processing.

Reading this might give you some insights too: http://doc.trolltech.com/qq/qq27-responsive-guis.html