Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

QPushButton background picture with text

$
0
0
What I’m trying to do is create a button that displays a background picture with a text message on top. This piece of code is the constructor for my UI form, and it works fine: FirstForm::FirstForm(QWidget *parent) :     QWidget(parent),     ui(new Ui::FirstForm) {     ui->setupUi(this); /*     setStyleSheet("QLabel { border-radius: 20px; border: 2px solid #000000 }"                   "QPushButton { border-radius: 20px; border: 2px solid #0000FF; background-color: #FFFF00 }"); */     QPixmap pixmap(":/Icons/User_Icon.png");     QPalette palette;     QPushButton *myButton = new QPushButton(this);     palette.setBrush(myButton->backgroundRole(), QBrush(pixmap));     myButton->setFlat(true);     myButton->setAutoFillBackground(true);     myButton->setPalette(palette);     myButton->setGeometry(670, 20, 86, 91);     myButton->setFont(QFont("Mufferaw", 12, 50));     myButton->setText("Sign In"); } I have several other pushbuttons defined on the UI form, and I’d like all of them all to have the style in the setStyleSheet section except for myButton. When I uncomment the setStyleSheet section, though, myButton doesn’t display the background image (I just see the yellow background with the text). What do I have to do to get myButton to display properly while keeping the setStyleSheet section?

Viewing all articles
Browse latest Browse all 18427

Trending Articles