PDA

View Full Version : QGraphicEffects not working on second thread



eric_vi
11th March 2011, 01:04
i am trying to run a QGraphicsBlurEffect on a second thread, not the main UI, it does not seem to work, on the main the same code works perfectly!

Is that normal?

Is there anyway around?

Thanks in advance

schnitzel
11th March 2011, 01:18
accessing GUI from other threads is not a good idea AFAIK - can you not send a message from the other thread instead?

eric_vi
11th March 2011, 15:09
is QGraphicBlurEffect considered as a GUI? I do not see anything in the doc about it,i am using it offscreen.

My problem is that i have a very time consuming process that involves QGraphicBlurEffect so i am doing it in a second thread, now will it work if i extract my function that call QGraphicBlurEffect put it in the main thread, then from the second thread call this function? If so how do you send a signal from another thread to the main one?

wysota
11th March 2011, 16:47
is QGraphicBlurEffect considered as a GUI?
Yes, it works on pixmaps.


My problem is that i have a very time consuming process that involves QGraphicBlurEffect so i am doing it in a second thread, now will it work if i extract my function that call QGraphicBlurEffect put it in the main thread, then from the second thread call this function? If so how do you send a signal from another thread to the main one?

What is this time consuming process?

eric_vi
11th March 2011, 18:10
too bad...

i have some heavy image computation on hundreds of pictures , i have to launch multiple threads for that.

Would it work if i place the code involving the QGraphicsBlurEffect in the GUI thread, then on my other threads when needed, i interrupt like with a QTimer so i can launch a signal to process my buffers in the GUI thread?

wysota
11th March 2011, 18:17
i have some heavy image computation on hundreds of pictures
And where does QGraphicsBlurEffect fit into this?

eric_vi
11th March 2011, 19:02
because it is part of the different algorithms i use in my offscreen processing. The blurring effect of QGraphicsBlurEffect that i apply on my buffers thru a transform to QPixMap fits well what i need. If i code the blur algorithm myself all work well, that is what i was doing before, but i have more speed with QGraphicsBlurEffect so i want to use it.

wysota
11th March 2011, 19:12
If you code the blur effect yourself, you can use OpenCL or texture shaders to get speedup. If you don't want that then you can still use Qt's blurring algorithm - either cut it out of Qt's sourcecode or adjust your code and call the internal function responsible for performing the blur in Qt. QPixmap can only be used in the GUI thread so you should probably focus on transforming QImage instead.