I have a QPushButton on my main window:
practiceButton_ = new QPushButton(this);
practiceButton_->setText(_("Practice"));
practiceButton_->setObjectName("practiceButton");
Then I associate some style with it:
qApp->setStyleSheet("QPushButton#practiceButton { background-image: url('myfile.png'); padding:0; margin:0; border:none; }");
The background image shows up and it looks like the style is applied successfully, however the button is smaller than the background image. How can I make it resize to fit its background image?
If it cannot be done automatically, is it possible to access the style applied to the button somewhere, and resize the button based on it? I’d just like to avoid hard-coding the values if I can avoid it.
1 Answer