[Qt] No icons on QT top-level menuitems

Juha Manninen juha.manninen62 at gmail.com
Wed Nov 9 11:24:44 CET 2011


Zeljan

I changed :

TQtWSMenuItem.AttachMenu
TQtWSMenuItem.CreateMenuFromMenuItem
TQtWSMenuItem.CreateHandle

and added method TQtMenuBar.addMenuWithIcon.

The problem I was trying to solve is that icons don't show on top-level QT
menuitems. They show nicely with GTK2 and Windows bindings.
There was another related problem: when there was an icon (ImageIndex)
defined for a top-level menuitem then icons from all sub-menus disappeared,
too.
It was easy to fix by not setting icon for the QT top-level menus in
CreateHandle.

I still failed to fix the problem properly. I was able to get either text
or icon to show but not both. Is it possible that QT can't do it?
There is even an API call that takes both icon and title as params. See
below.

My experimental TQtMenuBar.addMenuWithIcon calls
  QMenuBar_addMenu(handle: QMenuBarH; icon: QIconH; title: PWideString)
in hope that both text and icon would show. They don't. Only icon shows and
sub-menus don't work. The func returns QMenuH which should be used somehow
I guess.

I also refactored TQtMenuBar.SetActions out from TQtMenuBar.insertMenu.
While debugging it I noticed that after each menu item addition it clears
GlobalActions and then fills it.
It slows down polynomially when menu items are added. Yet, it does not
cause a visible slowdown.

I don't have more ideas. Could you please look at the icon related code.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/qt/attachments/20111109/ca6d503a/attachment-0002.html>


More information about the Qt mailing list