Qpushbutton qwidget background texture

Source: Internet
Author: User

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.