Re: how to stretch background image of pushbutton on button resize?
how to stretch background image of pushbutton on button resize?
i tryed this code. But not worked at all. its works for frame, central widgets, labels but not working on pushbutton
Code:
{
ui->centralWidget->setGeometry(0,0,e->size().width(),e->size().height());
ui->pushButton->setGeometry(0,0,(e->size().width())/2,(e->size().height())/2);
QPalette let
= ui
->pushButton
->palette
();
QSize size
(ui
->pushButton
->width
(),ui
->pushButton
->height
());
QString main
=":/M_alertBtncontinueUpNews.png";
QPixmap pixmapmain
(pixmapmain1.
scaled(size
));
let.
setBrush(QPalette::Background,pixmapmain
);
ui->pushButton->setPalette(let);
ui->pushButton->setAutoFillBackground(true);
}
Added after 22 minutes:
i got the code...
this worked for me
Code:
ui->centralWidget->setGeometry(0,0,e->size().width(),e->size().height());
ui->pushButton->setGeometry(0,0,(e->size().width())/2,(e->size().height())/2);
QSize size2
(ui
->pushButton
->width
(),ui
->pushButton
->height
());
QPixmap pixmapmain2
(extpixmap
->scaled
(size2
));
QIcon exticon
(pixmapmain2
);
ui->pushButton->setIconSize(size2);
ui->pushButton->setIcon(exticon);