[Qt-interest] QGraphicsItem and Threads

Ole Streicher ole-usenet-spam at gmx.net
Mon Oct 19 16:21:40 CEST 2009


Hallo Enrico,

Enrico Ros <enrico.qt at email.it> writes:
>  the QBrush may allocate a QPixmap that is windowing-system dependant and 
> cannot be created outside of the main thread. As a rule of thumb: only use 
> QImages (or other non-gui classes) in threads.

I thought that QGraphicsScene stuff is the non-gui part while
QGraphicsView is the GUI representation? 

> Techniques for making the gui responsive while creating the items:
>  - if you have to load images, do it on threads and post a 'QImage *' to the 
> main thread. there you'll be able to convert it to QPixmap, or QBrush or 
> whatever

I just want to change the colors of all my items depending on some
sliders, mouse cursors etc.

Ideal would be ofcourse if I could render the graphics view first to an
image and then display the image as a whole instead of the view -- this
would also avoid the flickering I get in the moment. Is this easily
possible?

>  - if you have to load 100'000 items, divide them into chunks of.. say.. 100 
> items, and schedule the execution of the loading function with a zero-timer 
>  - you can run QApplication::processEvents(), maybe excluding some kind of 
> events while creating the items. 
>  - see Qt Quarterly 27: http://doc.trolltech.com/qq/qq27-responsive-guis.html

OK, I will test and read this. What is a bit disappointing is that I
have already a multithreading capable operating system on a
multiprocessor kernel and I still have to implement some kind of
cooperative multitasking by hand. OK, lets go back to the beginning of
the 90ths :-)

Thank you very much for your hints.

Best regards

Ole




More information about the Qt-interest-old mailing list