Results 1 to 5 of 5

Thread: add(draw) an icon(or image) to a QPixmap?

  1. #1
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default add(draw) an icon(or image) to a QPixmap?

    hi, i captured screen without mouse icon.
    bu i need screenshot with mouse icon.

    can i add(draw) a mouse icon or image on my screenshot Qpixmap?
    and How?
    Last edited by ascii; 20th November 2008 at 09:07.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: add(draw) an icon(or image) to a QPixmap?

    Convert the pixmap to a QImage, construct a QPainter for that image, paint whatever you like upon that image (using the painter).
    Save to modified image to a file.
    or: Convert back to a pixmap (if needed).

    HTH

  3. The following user says thank you to caduel for this useful post:

    ascii (20th November 2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: add(draw) an icon(or image) to a QPixmap?

    Thanks...
    Can you show me an easy simple?
    i want to add mouse icon?

  5. #4
    Join Date
    Aug 2008
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: add(draw) an icon(or image) to a QPixmap?

    Thanks...
    Can you show me an easy simple?
    i want to add mouse icon?

  6. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: add(draw) an icon(or image) to a QPixmap?

    try something like this
    Qt Code:
    1. ...
    2. QPixmap p("cursor-arrow.png");
    3. QPixmap pixmap = QPixmap::grabWindow(qApp->desktop()->winId());
    4. QPainter painter(&pixmap);
    5. painter.drawPixmap(mapToGlobal(QCursor::pos()), p);
    6. pixmap.save("test.png");
    7. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. The following user says thank you to spirit for this useful post:

    ascii (20th November 2008)

Similar Threads

  1. 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.