Results 1 to 9 of 9

Thread: QPixmap png transparency

  1. #1
    Join Date
    Mar 2013
    Posts
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QPixmap png transparency

    I have a png with transparency but when I run the application it became white.

    Do I have to do something to set the transparency?

  2. #2
    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: QPixmap png transparency

    You have to paint it on something else than white background
    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.


  3. #3
    Join Date
    Mar 2013
    Posts
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QPixmap png transparency

    I've a blue background and I see white at the transparency area.

  4. #4
    Join Date
    Dec 2011
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPixmap png transparency

    Show us how you're drawing your pixmap. Are you creating a pixmap and painting it to the screen, or are you doing something with QSS?

  5. #5
    Join Date
    Mar 2013
    Posts
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QPixmap png transparency

    if (!product["icon"].isEmpty()){
    QPixmap* pixmap = new QPixmap(product["icon"]);
    QIcon icon(*pixmap);
    QSize iconSize(pixmap->width(), pixmap->height());
    button->setIconSize(iconSize);
    button->setIcon(icon);

    button->setFixedSize(pixmap->width(),pixmap->height());
    //button->setFlat(true);
    }

  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: QPixmap png transparency

    Apart from superflous use of the new operator this code is fine. The problem has to be elsewhere (e.g. your image is not transparent).
    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
    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: QPixmap png transparency

    .. or you are viewing your image on top of a white background.

  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: QPixmap png transparency

    That's what I already suggested but OP insists the background is blue
    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.


  9. #9
    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: QPixmap png transparency

    Indeed, please forgive my failure of early morning reading comprehension.

Similar Threads

  1. Replies: 9
    Last Post: 18th July 2011, 12:39
  2. QPixmap, PNG and Transparency
    By jsmax in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2010, 13:19
  3. Replies: 4
    Last Post: 28th August 2008, 13:13
  4. Replies: 1
    Last Post: 21st August 2008, 07:44
  5. Replies: 5
    Last Post: 9th April 2007, 14:26

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.