Search code examples
stylesheetpyqt5qmenubar

How to change right-arrow icon to access hidden menu items in QMenuBar using PyQt5?


enter image description here

I found no references about this in the documentation.


Solution

  • You cannot easily style this "extension" button because that symbol is actually an icon.

    You can however access the QToolButton widget to set the icon to whatever you like. In PyQt4 you get to it with menubar.children()[0]. This should be consistent with PyQt5. Looking at the Qt5 source code, it appears that the extension icon is always created first, even if it is not shown, and the children() method returns objects in the order in which they were created (this the index of 0).

    Once you have a reference to the QToolButton, you can then set the icon to whatever you like with menubar.children()[0].setIcon(my_qicon) (or similar).