Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a model as a source for a QMenu

I created a model which list the existing configurations (let's say it lists "files", as this doesn't really matter here). So far, it works well when attached to a QListView.

Example:

--- ListView ---
- file #1      -
- file #2      -
- file #3      -
- file #4      -
----------------

Is it possible to use the same model for a dynamically updated QMenu ?

Something like:

Menu
-> Submenu #1
-> Submenu #2
-> File-submenu
  -> file #1
  -> file #2
  -> file #3
  -> file #4
-> Submenu #3

In short: is there any way to create a list of dynamicaly updated QActions (grouped into the same QMenu) depending on a model (derived from QAbstractListModel) ?

like image 710
ereOn Avatar asked Jun 28 '10 16:06

ereOn


1 Answers

Unfortunately there is no QMenuView class but I found this promising implementation on the net: QMenuView (qmenuview.h, qmenuview.cpp).

like image 105
Frank S. Thomas Avatar answered Sep 27 '22 18:09

Frank S. Thomas