Results 1 to 6 of 6

Thread: Painting into QPixmap

  1. #1
    Join Date
    Jun 2008
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Painting into QPixmap

    The task is to display the image with list of overlays(rectangle or circle) and store them into a file.

    The current implementation is,
    1) We use custom widget that is derived from QWidget that paints the image and its overlays. All the implementation is in painter event.
    2) We store the content with grabWidget.


    Now we want to change the logic,

    We have introduced worker thread where in storing the images can be implemented. Can I use QPixmap as painter device in worker thread?

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Painting into QPixmap

    Quote Originally Posted by jessiemmichael View Post
    Can I use QPixmap as painter device in worker thread?
    Yes
    The QPixmap class is an off-screen image representation that can be used as a paint device.

  3. #3
    Join Date
    Jun 2008
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting into QPixmap

    I noticed in one the replies of Wysota's for " real time data display" that having reference to QPixmap in worker thread is not safe.

    I guess it is not possible to manipulate image and overlays into Qpixmap object in worker thread.

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Painting into QPixmap

    Thats true, in that case you can use painting on QImage.

    From Qt Docs:
    Painting in Threads:
    QPainter can be used to paint onto QImage, QPrinter, and QPicture paint devices. Painting onto QPixmaps and QWidgets is not supported. On Mac OS X the automatic progress dialog will not be displayed if you are printing from outside the GUI thread.
    More Info here.

  5. #5
    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: Painting into QPixmap

    Quote Originally Posted by yogeshgokul View Post
    Yes
    The QPixmap class is an off-screen image representation that can be used as a paint device.
    No. QPixmap is an on-server image representation that can't be used from worker threads. QImage can.
    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.


  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Painting into QPixmap

    Quote Originally Posted by wysota View Post
    No. QPixmap is an on-server image representation that can't be used from worker threads. QImage can.
    Yeah, I know, just got confused with the meaning of worker thread, I knew this phrase as NON-GUI thread. But now I will also call it same.

    I already accepted that and proposed same.
    Quote Originally Posted by yogeshgokul View Post
    Thats true, in that case you can use painting on QImage.

Similar Threads

  1. Position in a QPixMap created from a QGraphicsScene
    By stevel in forum Qt Programming
    Replies: 8
    Last Post: 8th April 2009, 22:39
  2. QPixmap memory handling
    By Angelo Moriconi in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 15:37
  3. Replies: 4
    Last Post: 28th August 2008, 13:13
  4. Loading a QPixmap from raw data
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2008, 10:12
  5. QPixmap and HBITMAP
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 16:24

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.