How to add two icons/images to the same QPushButton??
Hi,
How to add two icons/images to the same QPushButton.
ie, i want to add one icon with alignment left and another in the center besdes to the text ??
i'm doing the following but it shows only one icon
Code:
championbtn->setText("any");
championbtn
->setIcon
(QIcon(":/images/DEFAULT-LOGO.png"));
championbtn
->setIcon
(QIcon(":/images/CLOSE.png"));
championbtn
->setIconSize
(QSize(31,
31));
thanks
Ram
Re: How to add two icons/images to the same QPushButton??
setIcon will only set one image
Code:
championbtn
->setIcon
(QIcon(":/images/DEFAULT-LOGO.png"));
championbtn
->setIcon
(QIcon(":/images/CLOSE.png"));
in this code , the CLOSE.png will be set to the button.
simple solution will be just add the two images in imageeditor. and load it.
hope it helps
Bala
Re: How to add two icons/images to the same QPushButton??
thanks bala,
i'm newbie to QT and don't know how to do that, so please give me sample code, link or more details
thanks
Re: How to add two icons/images to the same QPushButton??
Hi ram4soft,
Instead of you can merger two images and then apply them to the pushbutton
The syntax can be like this...
Code:
QPixmap firstImage
(":/QTTestProject/images/Image-01.png");
//qrc path QPixmap secondImage
(":/QTTestProject/images/Image-02.png");
//qrc path
painter.drawPixmap(0, 0, firstImage);
painter.drawPixmap(firstImage.width(), 0, secondImage);
dummyIcon.addPixmap(comboPixmap);
championbtn->setIcon(dummyIcon);
Note: Set the comboPixmap size based on the "Image-01.png" and "Image-02.png".:)