Hi,

I continue to find it strange that Qt would introduce a convenience method to 
add labelled sections to menus if that feature isn't available on all 
platforms. I understand there are limitations to what native menus in native 
menubars can show but not the step from that fact to an official attitude "just 
don't use QMenu::addSection on those platforms". Yet that's exactly how a bug 
report I filed on this topic was closed (a while back). I read that as "just 
don't use QMenu::addSection in cross-platform code", which in practice 
translates to "just don't use QMenu::addSection" - at all.

Is this still the official stance or has it been mellowed with time and insight 
that organising menus with labelled sections can be useful in applications with 
a rich (complex) GUI?

Again, I can understand that "texted separators" created with something like 
`menu->addSeparator()->setText("this may be a section label")` don't have the 
same appearance everywhere. A dedicated method `menu->addSection("This will be 
a section")` suggests otherwise, though.

I've been playing around with the code after I discovered the existence of the 
corresponding style hint and am testing a patch that attempts to provide a 
reasonable rendition of a "texted separator":

if SH_Menu_SupportsSections is false, use the emulation
else:
  if the menu belongs to a native menubar on Mac (or MS Windows?), use emulation
  else texted separators should work just fine.

IOW, on Mac emulation is only necessary when using the native widget style or 
else for menus attached to the native menubar.

Emulation is really quite simple: if the above check indicates it's required, 
add an additional regular but deactivated QAction to the menu holding the 
section text before adding the texted separator action. It would be nice if 
there were a way to centre the text of the disabled menu item but the result is 
close enough to a style that renders the section entry with underlined text. In 
either case it's up to the application to use a section text label that doesn't 
make the user think the menu entry should actually do something.

This emulation is done when the menu is constructed so the overhead associated 
with determining if the menu belongs to a native menubar should be acceptable.

R.

PS: am I right that even the Macintosh style could actually support texted 
separators in context menus and nonnative-menubar-menus?
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to