View Full Version : QMenu indicator style sheet undesired behaviour

6th August 2019, 10:38
Hello there,
In one of my projects, I used to define my own application theme (via style sheets).

Everything worked fine except when I tried to set an image for the QMenu::indicator:exclusive:checked state.
In fact, it works fine for the checked item but it generates collateral undesired behaviour over unchecked items.
Indeed, if I define an image for the checked indicator, the unchecked indicators become sunk and I don't understand why (and nothing worked to remove it: removing borders, changing border-style, setting an empty image, setting a not empty image, ... nothing seems to affect this ugly sunken border).

You can find the details (context, screenshots, ...) of the problem in the original question here (https://stackoverflow.com/questions/57360526/setting-qmenuindicatorexclusivechecked-stylesheet-causes-undesired-behaviour).

If someone has an idea of how to get rid of it, I would be very grateful.

Thanks in advance for those who will spend some time to help me.

EDIT: After performing additional tests, it seems to be a bug. I reported it on the Qt bug tracker, you can find it here (https://bugreports.qt.io/browse/QTBUG-77344?filter=-6).

6th August 2019, 19:21
Stylesheets are nice for small and few changes, for anything beyond that it is usually a better idea to invest in a proper QProxyStyle.


7th August 2019, 09:09
First of all, thank you for your answer.

I agree with this for elaborated design, it is better to use something else than stylesheets.
But, I think even for the style of a whole application, if we stay in the scope of stylesheets capabilities, I don't see a reason why it should be bad to use them.

The problem here is that I don't have any elaborated effects that exceed the stylesheets capabilities and applying the stylesheet does not behave as it should do.
So the problem is not about stylesheets capabilities but more about the way they are implemented in Qt (what Qt does when we apply a stylesheet with setStyleSheet()). And this is where I found the bug.

In the bug report (https://bugreports.qt.io/browse/QTBUG-77344?filter=-6), I have added a minimal and complete example to reproduce the bug.

Thanks for your advice anyway :)

13th November 2019, 15:36
There is some example of QMenu indicator stylesheet here : https://qss-stock.devsecstudio.com

20th February 2020, 11:13
Have you found any workaround for this bug?
Maybe it is possible to customize checkmark without drawing this frame for unchecked state?