QPushButton stylesheet problem
Whenever I set a stylesheet on a QPushButton, the button's appearance changes unexpectedly when running the application. For example, using the following stylesheet:
Every looks fine in Qt Designer:
http://img229.imageshack.us/img229/9631/designerz.png
But when I run the application I get the following result:
http://img229.imageshack.us/img229/692/window.png
This is using Qt 4.5.2. How do I fix this?
Re: QPushButton stylesheet problem
What's the problem? The color is red. Everything fine... In your final program your button has the focus and therefore the focus rectangle. If you don't like it, change it.
Re: QPushButton stylesheet problem
Thanks, the input focus indeed causes the rectangle. However, when I do not set any stylesheet, the input focus rectangle is not displayed when the button has focus. It seems that setting any custom stylesheet causes the input focus rectangle to be displayed when the button has input focus.
How can I prevent this? Or, how should I adapt my stylesheet to ensure that the input focus rectangle is not displayed?
Re: QPushButton stylesheet problem
To illustrate, this is how a button with input focus looks in case no stylesheet has been set (the upper button has input focus):
http://img228.imageshack.us/img228/8099/normalm.png
Re: QPushButton stylesheet problem
what style do you use? normally I only know a dashed or dotted rectangle as focus. And how does your complete style sheet looks like? May be you have there other settings causing your problem.
And please add your images at the thread and not at a 3rd party site, so that your post stays consistent also in future.
Lykurg
Re: QPushButton stylesheet problem
You can add a pressed and hover state to your style sheet to make it behave as you wish
QPushButton { ... }
QPushButton:pressed {...}
QPushButton:hover {...}
QPushButton:disabled {...}
You probably want to put in
color: red;
background: (whatever color you want)
Re: QPushButton stylesheet problem
Quote:
Originally Posted by
Lykurg
what style do you use? normally I only know a dashed or dotted rectangle as focus. And how does your complete style sheet looks like? May be you have there other settings causing your problem.
And please add your images at the thread and not at a 3rd party site, so that your post stays consistent also in future.
Lykurg
I'm using Gnome, Ubuntu 9.04. If I understand correctly, Qt defaults to QGtkStyle in my case. For the application in the screenshots above, no other stylesheets have been specified anywhere except for the
part. So I expect it is buggy behaviour in the QGtkStyle that such a stylesheet causes a complete change in the input focus rectangle appearance. I'll file a bug for this case.
Re: QPushButton stylesheet problem
Quote:
Originally Posted by
ntp
You can add a pressed and hover state to your style sheet to make it behave as you wish
QPushButton { ... }
QPushButton:pressed {...}
QPushButton:hover {...}
QPushButton:disabled {...}
You probably want to put in
color: red;
background: (whatever color you want)
I may be able to mimick the default QGtkStyle behaviour, but in case the application runs in a different Gnome environment with different theme settings it's look will not be consistent with other applications. So I don't like this approach although it may work.
3 Attachment(s)
Re: QPushButton stylesheet problem
These are the images that were posted above.
Re: QPushButton stylesheet problem
Quote:
Originally Posted by
blukske
So I expect it is buggy behaviour in the QGtkStyle that such a stylesheet causes a complete change in the input focus rectangle appearance. I'll file a bug for this case.
Have you tried an other style? The same there?
Re: QPushButton stylesheet problem
Quote:
Originally Posted by
Lykurg
Have you tried an other style? The same there?
Yes, I just tried QCleanlooksStyle and the problem did not occur. I assume now that QGtkStyle is the problem. I just filed a bug and will post the link here as soon as it is accepted.