PDA

View Full Version : Custom QMenu



ArlexBee-871RBO
21st November 2009, 11:24
Greetings.

QMenu lists its actions vertically, but I need a menu that lists actions vertically and horizontally (basically, you see a grid of actions when you click, say, File, and not just a list). I've subclassed QWidgetAction, but I can't figure out how to add them to the menu.

I can't add a grid layout to the menu, so what is the proper way of doing this?

Thanks

wysota
21st November 2009, 12:04
Why did you subclass QWidgetAction and not QMenu? The former is for placing widgets in toolbars or menus. If you want a custom menu it would seem you should base on QMenu. On the other hand none of QMenu methods are virtual...

ArlexBee-871RBO
22nd November 2009, 00:07
I subclassed QWidgetAction because I need custom widgets for the actions, but we can ignore that part. Just think QAction objects.

I did subclass QMenu, but I just can't figure out a way to do what I want. I can't just insert a grid layout into the menu, and there is no way to tell QMenu to have a minimum row count so that it wraps around and forms the next column.

I think I'll have to subclass QWidget and design a custom menu.