QMenu addSection Not Showing
Is there any reason why the
addSectionfunction of a
QMenuwould have no effect?
For example, the following code:
QMenu menu; menu.addSection("Connected"); menu.addAction("None"); menu.addSeparator(); menu.addSection("Available"); menu.addAction("None"); menu.addSeparator(); menu.addAction("Quit");
Results in a menu with just the actions and separators visible.
From the documentation from addSection:
The rendering of the hint is style and platform dependent. Widget styles can use the text information in the rendering for sections, or can choose to ignore it and render sections like simple separators.
@SGaist thanks for the clarification - so I can presume then, that Windows does not render these sections. Thanks again.
I've experienced this very same problem and although I'm very late to the discussion I have to say that it's possible to render separators and separator labels in Windows. The trick is to use a widget style that supports these features.
One such widget theme is the "fusion" style shown in Qt's wiget gallery. For a quick test, just run the Qt application with the fusion style by passing the "-style fusion" command line argument.