1. qpushbutton: although it is simple, it takes me time to find the image. Share it with people in urgent need.
Note: pright1 is the new button.
Const char * normal1 = ":/images/pic01.jpg ";
const char* pressed1 = ":/images/pic01_on.png";
char str1[512] = {0};
sprintf(str1,"QPushButton{background-image:url(%s);border-style:flat;background-attachment:fixed;}QPushButton:hover:pressed{background-image:url(%s);border- style:flat;background-attachment:fixed;}", normal1, pressed1);
pRight1->setStyleSheet(QString(str1));
2. widget background texture
QPixmap pixmap(":/images/bg.png");
QPalette palette;
Palette. setbrush (this-> backgroundrole (), qbrush (pixmap); // when you use this sentence separately, the background color of the listwidget in the layout is still the original
Palette. setbrush (qpalette: Base, qbrush (pixmap ); //
palette.setBrush(QPalette::Window, QBrush(pixmap));
this->setPalette(palette);
// This-> setmask (pixmap. Mask (); // you can display the transparent part of the image as transparent, which causes a problem when maximizing the window.
this->setAutoFillBackground(true);