QToolButton Style
-
Hi
Not showing when the button is activated is not optimal as some,
including me, will think it's not active
and just not painted dark enough as disabled
due to the new design style that is most mono-color so disabled buttons are hard(er) to spot.You can use a proxy style to disable the "press" effect
class ToolButtonProxy : public QProxyStyle { public: int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override { int ret = 0; switch (metric) { case QStyle::PM_ButtonShiftHorizontal: case QStyle::PM_ButtonShiftVertical: ret = 0; break; default: ret = QProxyStyle::pixelMetric(metric, option, widget); break; } return ret; } };
ui->MYBUTT->setStyle( new ToolButtonProxy() );
-
Hi,
Out of curiosity, what is the issue with the fact that the button sinks ?
Removing the animation would make the use of your toolbar a bit awkward with regard to the usual GUI guidelines. -
@Saviz
well yes if you style it.QToolButton { border: 2px solid #8f8f91; border-radius: 6px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde); } QToolButton:pressed { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde); }
-
Then why use a button at all if you in fact don't want a button ?
Create your own clickable widget, it will be simpler than trying to get rid of what makes a button behave like a button.
-
Since I can't explain it correctly I decided to add a video to demonstrate the problem.
As you can see In my side bar the QToolButton sinks way too much and I don't like that. Many apps have it so the button is stationary and doesn't do that animation. Is that achievable?
(What's wrong with wanting a button that dose not sink ? :/ The QPushButton doesn't do that as well.)
-
Hi
Not showing when the button is activated is not optimal as some,
including me, will think it's not active
and just not painted dark enough as disabled
due to the new design style that is most mono-color so disabled buttons are hard(er) to spot.You can use a proxy style to disable the "press" effect
class ToolButtonProxy : public QProxyStyle { public: int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override { int ret = 0; switch (metric) { case QStyle::PM_ButtonShiftHorizontal: case QStyle::PM_ButtonShiftVertical: ret = 0; break; default: ret = QProxyStyle::pixelMetric(metric, option, widget); break; } return ret; } };
ui->MYBUTT->setStyle( new ToolButtonProxy() );