PDA

View Full Version : QMenu: want a QListView in submenu to handle lots of options



chezifresh
10th November 2009, 20:46
One major down side to the QMenu class is if you need to add a lot of items to it, it begins to wrap around the screen if one column can't fit.

In Qt3 I was able to relatively easily add a list view to a menu to solve this problem. If you get too many things in the menu it simply scrolls instead of adding another column. In Qt4 this seems to be far harder or at least elusive to me.

The closest thing I can find that uses this in Qt4 is the QCompleter when showing a popup. However, it just shows a QAbstractItemView by setting its geometry and displaying it. I want to display a QListView in much the same way but as a submenu of a context menu but have no clue how to do it.

ie:


Cut Ctrl+X
Copy Ctrl+C
Paste Ctrl+V
---------
Versions > // <-- this submenu would be a QListView with potentially a bunch of items in it
Any ideas?

chezifresh
13th November 2009, 00:55
Has anyone tried QWidgetAction with this? I can get the list view to show up but can never get the menu to disappear on click.