Results 1 to 8 of 8

Thread: QGraphicEffects not working on second thread

  1. #1
    Join Date
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default QGraphicEffects not working on second thread

    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

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicEffects not working on second thread

    accessing GUI from other threads is not a good idea AFAIK - can you not send a message from the other thread instead?

  3. #3
    Join Date
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default Re: QGraphicEffects not working on second thread

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicEffects not working on second thread

    Quote Originally Posted by eric_vi View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default Re: QGraphicEffects not working on second thread

    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?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicEffects not working on second thread

    Quote Originally Posted by eric_vi View Post
    i have some heavy image computation on hundreds of pictures
    And where does QGraphicsBlurEffect fit into this?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default Re: QGraphicEffects not working on second thread

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicEffects not working on second thread

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 5
    Last Post: 22nd February 2011, 21:21
  2. Replies: 1
    Last Post: 9th October 2010, 23:54
  3. Replies: 9
    Last Post: 28th November 2009, 20:31
  4. Replies: 16
    Last Post: 7th October 2009, 08:17
  5. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.