Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ID/name selectors for QMenu item styles?



  • I'm styling a QMenu with the following stylesheet:

        QMenu {
          ...
        }
        QMenu::item {
          ...
        }
        QMenu::item:selected {
          ...
        }
        #empty {
          ...
        }
    

    But, the #empty selector isn't working at all for a QWidgetAction. I've made sure to call setObjectName on it. I've tried naming the QMenu itself and using #menu in the CSS, which does work.

    What I'm trying to do is style it as if it was disabled, but still have it emit triggered signals.


  • Lifetime Qt Champion

    Hi
    I dont think you can style a QAction/QWidgetAction as such.
    But the widget underneath surely is.



  • Hmm, well, the menu will only have one item in it if the #empty item is in it, so I can probably just change the style for the menu, then set it back when another item is inserted.

    I'm curious, though, how I can set a style for just one item, because I imagine at some point I may have to do that.


Log in to reply