Reputation: 55
Searching around the internet I found a way to set up my own image for a QPushButton, with this line on style sheet:
border-image: url(:/Path/to/my/image.jpg) 0 0 0 0 stretch stretch;
And the result has a nice appearance, but it loses the "push effect".
With the line
backgound-image: url(:/Path/to/my/image.jpg);
It keeps the push effect but the background image does not scale to the size of the button like with "border-image"
Is there a trick I haven't found yet to make it work with the border-image or I have to change the size of my .jpg image in order to have my button style correct?
Upvotes: 2
Views: 4401
Reputation: 4049
You can put a style sheet on all the button state.
Take a look on the Qt documentation QPushButton stylesheet
Upvotes: 1
Reputation: 55
So, I found a way to do what I wanted, creating 2 different JPG images and setting each one to appear as the border-image in normal state and pressed state of the QPushButton, adding the following lines to the button's stylesheet:
QPushButton{ border-image:url(:/path/to/my/image.jpg); QPushButton:pressed{ border-image:url(:/path/to/my/image2.jpg); }
Works for me, I can say the problem is solved.
Upvotes: 2