Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Disable sinking of QToolButton when pressed
Is it possible to disable visual "sinking" effect of QToolButton when it is pressed? I have some customized buttons with visual feedback provided by icon change, and the additional shift of the icon by 1 pixel right and 1 pixel down is unnecessary and annoying.
qxoz last edited by
Well you always can customize QToolButton with "qss":http://qt-project.org/doc/qt-5/stylesheet-examples.html
The buttons are already customized with CSS (for example, they have custom borders), but I have no idea how to disable sinking with CSS. Changing border for QToolButton:pressed does not help.
qxoz last edited by
Can you tell me what OS and Theme you have, so i can test it?
And show screen shot of sinking QToolButton if possible.
Windows 7 64-bit Ultimate, Qt 5.2.1, MinGW 32-bit compiler, default theme (I do not use any custom themes). Here is a simple CSS (applied for the entire application) I use for testing:
border: 1px solid blue;
border: 1px solid red;
The 'border' property works, the button looks as a colored rectangle with an icon inside, nothing else. I can see border color changing when the button is pressed, but there is also a visible move of the button icon right and down. The icon is set by the QToolButton::setIcon method in the code and (in the test case) is the same for all button states.
I have found "this thread":http://qt-project.org/forums/viewthread/15517 and tried to use QProxyStyle, but without success. I have created a subclass of QProxyStyle, FlatToolButtonProxyStyle, as suggested, and applied it to my tool button:
It does nothing. Moreover, when I run the application under debugger, pixelMetric method of FlatToolButtonProxyStyle is never called.
Marco Feuerstein last edited by
The same just happened to me. pixelMetric simply wasn't called because I forgot to declare it const.