Results 1 to 3 of 3

Thread: Drawing a QPixmap transparently with QPainter

  1. #1
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Drawing a QPixmap transparently with QPainter

    Problem:

    I have a QPixmap that already has an alpha channel. I want to use QPainter to drawPixmap() a QPixmap, but I want to draw it halfway transparent. I do not want to edit the QPixmap itself, unless I can easily undo the edit... thousands of times a frame.

    ---------------------------------
    Scenario:

    Basically, I already have a QGraphicsScene with plenty of transparent QPixmaps, but I want to temporarilly draw a number of them (but not all) transparently, in response to the user's actions.

    ---------------------------------
    Question:

    Can I get QPainter to transparently draw a QPixmap?

    Something like: painter->drawPixmapTransparently(x, y, pixmap, transparency

    Or:

    Can I temporarily adjust the alpha of an entire QPixmap image, without permanently adjusting it's alpha channel?

    Something like: pixmap->setAlpha(128)

    ---------------------------------

    I've looked through the documentation (ofcourse), but I can't seem to find what I'm looking for. Since I'm not too familiar with QT, I'm hoping I've just overlooked the feature somewhere.

    Thank you in advance!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Drawing a QPixmap transparently with QPainter


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

    ComServant (11th October 2010)

  4. #3
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Drawing a QPixmap transparently with QPainter

    Yes, thank you, that was exactly what I was looking for. I was looking for 'alpha', and 'transparency'... but it was named 'opacity'. =)

    Other APIs have similar, so I figured I must've just been overlooking it somewhere.

    Thanks again, Chris, I apreciate the help.

Similar Threads

  1. QPainter and complex drawing : advices
    By toutarrive in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2009, 10:51
  2. Drawing QIconSet-s on a transparent QPixmap ?
    By ultr in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 14:10
  3. drawing on a QPixmap or QImage
    By gren15 in forum Newbie
    Replies: 15
    Last Post: 3rd March 2009, 17:48
  4. Replies: 4
    Last Post: 28th August 2008, 13:13
  5. Drawing speed: QPixmap vs QPicture
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2008, 19:17

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.