Results 1 to 10 of 10

Thread: QPixmap: It is not safe to use pixmaps outside the GUI thread

  1. #1
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QPixmap: It is not safe to use pixmaps outside the GUI thread

    Hi everyone,
    I am using 3 thread (one gui(M) and two non-gui(X,Y)).In gui thread all display kind of things are there.If i want to display some thing form non gui thread then i am using the signal-slot concept.
    In X i am extracting frame from web cam and continuously sending it to gui thread for display. In Y i am doing some operation on that image.In this programme i am getting "QPixmap: It is not safe to use pixmaps outside the GUI thread" and the programme is crashed. This error occurs at any place and any time in gui thread where i am trying to stop displaying image or at message box.Maximum time it occurs after a particular message box.
    What can be the error ?How i solve this ?Is it due to thread synchronization ?

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    The warning message says it all. You can not use QPixmap outside gui thread. Try to use QImage.

  3. #3
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    thanks for reply
    But all QPixmap things are used inside gui thread.
    The programme is working fine in windows -7 ,qt 4.7 til now.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    Quote Originally Posted by bibhukalyana View Post
    But all QPixmap things are used inside gui thread.
    Used (=displayed) maybe, but most likely you also create one in a thread and send it to the gui thread. And this is as nish said not "possible". It could work but will crash at any time. So how do you work on the images in X and Y. What class to store do you use?

  5. #5
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    send the Qimage to the gui thread and convert using Qimgae::toPixmap()

  6. #6
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    In X i am extracting frame from web cam.I am using this code:http://opencv.willowgarage.com/wiki/CameraCapture for getting the IplImage and sending this image to gui thread.In gui thread i convert the IplImage to QImage and after that i set that QImage to lable converting it to QPixmap.

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    i did not get you. The problem is solved?

  8. #8
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    no it is not solved.
    I am converting the qimage to qpixmap in gui thread.

  9. #9
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    Note that some conversions between QImage and QPixmap are "const" and "share" the image buffer. You need to be sure that such sharing is NOT occurring.

  10. #10
    Join Date
    Mar 2011
    Posts
    120
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap: It is not safe to use pixmaps outside the GUI thread

    I did not get you.Can you explain more ?

Similar Threads

  1. thread-safe
    By babymonsta in forum Qt Programming
    Replies: 0
    Last Post: 5th May 2010, 11:18
  2. Why is QMutex Thread Safe?
    By Kind Lad in forum Newbie
    Replies: 3
    Last Post: 22nd February 2010, 05:46
  3. About the QSound,is thread safe?
    By cspp in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2009, 15:26
  4. What makes something not thread safe?
    By tgreaves in forum Newbie
    Replies: 9
    Last Post: 20th February 2009, 21:16
  5. need to draw on pixmaps outside of the gui thread
    By Serenius in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2009, 17:22

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.