On Sat, May 4, 2019, 6:19 AM Marcus Ottosson <konstrukt...@gmail.com> wrote:

> Yes, I’ve seen this too. Using CSS, some widgets require that you
> re-define not just individual elements, but the entirety of the widget and
> all of its children. So what’s happened here is that all elements of the
> menu forgot about any default styling as soon as you apply a stylesheet to
> the parent QMenu. I don’t think there’s any way to style just one element,
> I’ve always resorted to re-styling the whole thing, so if you find any, let
> me know!
>
It isn't the same issue as where you define one aspect of the style and the
widget loses all the other defaults from the QStyle. It is caused by this
being CSS (Cascading Style Sheets) and the "cascading" being the key word
here. The current form of that CSS selector is applying to the object and
all of its children. The menu has child menus so every matching checkable
action that is a descendent is being affected.
The qt stylesheet reference describes the different syntax for selectors :
https://doc.qt.io/qt-5/stylesheet-syntax.html#selector-types

There is a form of the selector that applies only to a specific object by
its id:

    #myObjectName

Or more specifically:

    QMenu#myObjectName

This would allow you to set unique object names on the menus and control
them individually.
Otherwise the alternative is to not parent the menus to each other but
rather the same top level widget.


> On Fri, 3 May 2019 at 18:28, kiteh <kiteh.0...@gmail.com> wrote:
>
>> Hi all,
>>
>> I am trying to implement a right-arrow in my QMenus and as soon as I did
>> that, it seems to have screw up my checkboxes?
>>
>> https://media.giphy.com/media/W0cTSdMJ0f0xDq7Xx9/giphy.gif
>>
>> The checkboxes you are seeing in the gif are actually QAction objects.
>> Wondering if anyone has experience this before and/or if this is a Maya/Qt
>> issue (I couldn't tell which is which) or if this could be one of the
>> instance where Maya does not plays nicely with Qt?
>>
>> I am using the following line of code to set the right-arrow in my QMenu
>> subclass:
>> self.setStyleSheet("QMenu::right-arrow{image:url(add.png);}")
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/7e29642a-2dbb-4dd2-a2de-e2621c4e7b61%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/7e29642a-2dbb-4dd2-a2de-e2621c4e7b61%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODUiNrvC9KtDUC64epQy0X2FS%3D9-7deESQ4%3DYYZMpyLzw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODUiNrvC9KtDUC64epQy0X2FS%3D9-7deESQ4%3DYYZMpyLzw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1Mcb6Cq6daA6eA5iOWN8rDx_a_KMGR8%2BpSyTRwC7rVaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to