Results 1 to 2 of 2

Thread: Placing a transparent image on a QPushButton

  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Placing a transparent image on a QPushButton

    Hi! I'm trying to put an image with a transparent background on a QPushButton for a Windows CE device. The problem is that I see the button on the background. I'm finding it difficult to remove it as I can't create a mask on a specific color as I used to do (I don't have the RGB color). Is it possible to do this? I read it is not possible to set window transparency in Windows CE, so that way is not applicable. Any other way to do this?
    Thanks!

  2. #2
    Join Date
    Jan 2010
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Placing a transparent image on a QPushButton

    Hello,

    Yes It is possible to do this in WinCE.
    Try this:

    //Image to put in the button with transparence
    QPixmap pixmapImage;
    //Load home image
    pixmapImage.load("Example.png");

    //Creates the button
    QPushButton * pButton;
    pButton = new QPushButton("widget_parent"); //this is the widget parent to adapt

    //Set transparence and the image
    QColor transparent_color(0,0,0,0);
    QPalette button_palette(pButton->palette());

    button_palette.setColor(QPalette::Button, transparent_color);
    pButton->setPalette(button_palette);

    pButton->setIcon(pixmapImage);
    pButton->setText("Example");
    pButton->setIconSize(m_PixmapHome.size());


    Hope this works for you;

    Diegol

Similar Threads

  1. Converting to transparent Image
    By navi1084 in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2009, 13:25
  2. Create Transparent PNG Image
    By hvitual in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2009, 14:35
  3. QPixmap(image) to transparent HBITMAP
    By ascii in forum Qt Programming
    Replies: 7
    Last Post: 2nd March 2009, 09:03
  4. How can I create a transparent image with QImage?
    By learning_qt in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2009, 15:06
  5. QPushButton with image on it
    By msmihai in forum Newbie
    Replies: 1
    Last Post: 6th January 2009, 20:53

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.