How to remove QPushButton border but keep effect
-
I'm trying to recreate the Float and Close button from the QDockWidget default title bar, they look like this:
I have figured out so far how to get that icon and as far:
auto icon = style()->standardIcon(QStyle::SP_TitleBarNormalButton, nullptr, this);
As I can see the icon has the three states that I require, normal, hover and pressed. Added to a QPushButton it looks as expected. Now I have removed the border by changing the StyleSheet:
button->setStyleSheet("QPushButton {border-style: outset; border-width: 0px;}");
The button looks now exactly as I need it to look but the problem is that there is no hover effect and if I click on the button it changes the icon to the pressed state as expected but when I release it, it stays in that state. Interesting is that when I click on the that same button of another dock widget, the first button goes back to normal state and the second button stays in the pressed state. Any idea what might be going wrong or what an alternative could be?
-
Hi
When you apply a stylesheet, the normal drawing is no longer in effect.
So you have to style it fully.
For hover, you might want to use ":hover" key to assign an effect.For the stay down, Im a bit baffled.
It really sounds like it's flagged as checkable and shares a button group with the other instances.
But Not sure where that would come from.
You set a custom widget to title bar ?