Results 1 to 2 of 2

Thread: how to paint a transparant qpixmap on a pushbutton

  1. #1
    Join Date
    Mar 2013
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to paint a transparant qpixmap on a pushbutton

    Hi I have to put a pixmap with opacity on a pushbutton.ï½”
    I checked on line and tried, the following is my code:


    livePushButton = new QPushButton(centralWidget);
    QPixmap pixmap("../icons/live.PNG");
    QIcon icon(pixmap);
    livePushButton->setIcon(icon);
    livePushButton->setIconSize(QRect(0, 1020, 256, 90).size());
    livePushButton->setObjectName(QString::fromUtf8("livePushButton") );
    livePushButton->setGeometry(QRect(0, 1020, 256, 90));

    The pixmap is drawn on the pushbutton, when I insert the pixmap.fill(Qt::transparent); to the code, the pixmap disappeared. that means the pixmap was transparent completely.

    livePushButton = new QPushButton(centralWidget);
    QPixmap pixmap("../icons/live.PNG");
    pixmap.fill(Qt::transparent);
    QIcon icon(pixmap);
    livePushButton->setIcon(icon);
    livePushButton->setIconSize(QRect(0, 1020, 256, 90).size());
    livePushButton->setObjectName(QString::fromUtf8("livePushButton") );
    livePushButton->setGeometry(QRect(0, 1020, 256, 90));

    how I can draw the pixmap with the opacity 0.75? I am a starter, , and many thanks for any advice!


    Added after 25 minutes:


    Thanks, solved.
    Last edited by Sumiko; 8th March 2013 at 19:18.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to paint a transparant qpixmap on a pushbutton

    Thanks, solved.
    How?

    The reason why there are forums like this is so people can help each other. You can ask for help, and if someone can help you they will. At the same time, you should be ready to help someone else. So if you managed to solve the problem yourself, then it would be nice if you shared the solution with the rest of the forum members, instead of just posting "solved".

Similar Threads

  1. glitchy QPixmap drawing on paint area
    By Lapsio in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2012, 20:04
  2. Replies: 5
    Last Post: 8th July 2011, 08:06
  3. Replies: 3
    Last Post: 29th April 2011, 08:54
  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.