Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2011-11

No icons on QT top-level menuitems

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

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.freepascal.org/pipermail/qt/attachments/20111109/ca6d503a/attachment.html>

Juha Manninen
to Juha Manninen

... and ...
the code is now better than before. A user can now place an image on a top-level menuitem if he wants (although the text caption is lost). Also, setting such image does not prevent all sub-menu images from showing.

If there is no better solution then obsolete code like TQtMenuBar.addMenuWithIcon
can be removed.
However I have a hunch you could improve it because you know QT and the bindings so well.

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

zeljko
to Juha Manninen: Zeljan I changed : TQtWSMenuItem.AttachMenu TQtWSMenuItem.CreateMenuFromMenuItem…
Juha Manninen wrote 36 lines
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.

When did you changed ? svn ?

Icons are shown in menus if theme/style says so, so I don't know why would you change code ? I don't understand what's goal of such change.

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/qt/attachments/20111109/f2f5cdce/attachment-0001.html>

Felipe Monteiro de Carvalho
to zeljko

Just a side note: This feature looks useless to me, I don't remember ever seeing an application which uses icons in the top-level main menu items. And also not portable (thinking about Mac OS X, smartphones)

Felipe Monteiro de Carvalho