PDA

View Full Version : how to paint a transparant qpixmap on a pushbutton



Sumiko
8th March 2013, 20:18
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. :);):rolleyes::o

d_stranz
10th March 2013, 00:35
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".