728x90
1. QPushButton에 배경이미지 넣기
void setButtonBackImage(QPushButton *button,QString image,int sizeW, int sizeH)
{
//163,163 Is the original resolution , Here's a little adjustment .
QPixmap pixmap(image);
QPixmap fitpixmap=pixmap.scaled(163,163).scaled(sizeW, sizeH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
button->setIcon(QIcon(fitpixmap));
button->setIconSize(QSize(sizeW,sizeH));
button->setFlat(true);// This is the sentence that can make the button transparent , use png It's very useful when using pictures
button->setStyleSheet("border: 0px");// Remove borders , Cancel the click effect
}
2. QWidget에 배경이미지 넣기
this->setAutoFillBackground(true); //Widget When adding background pictures , This must be true .
QPixmap pixmap(":/images/bg_news.png");
QPixmap fitpixmap=pixmap.scaled(1200, 1200).scaled(config->mainWindowW,config->mainWindowH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QPalette palette;
palette.setBrush(QPalette::Background, QBrush(fitpixmap));
this->setPalette(palette);
3. QLabel 에 배경이미지 넣기
QPixmap pixmap(normalIcon);
QPixmap fitpixmap=pixmap.scaled(labelIcon->width(), labelIcon->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
labelIcon->setPixmap(fitpixmap);
4. QSS StyleSheet를 이용하여 배경이미지 넣기 (사이즈 변경 불가)
lastBtn->setStyleSheet("background-image: url(:/images/btn_previous_normal.png);border: 0px");
5. QPixmap 이미지 회전하기
QMatrix leftmatrix;
leftmatrix.rotate(270);
ui->label->setPixmap(pixmap.transformed(leftmatrix, Qt::SmoothTransformation));
728x90
728x90