tags:

views:

120

answers:

1

I was wondering if there is a way to convert my QT (version 4.50) menu and all its submenus into a text document in something similar to the following format:

  • Menu 1
    • Sub Menu 2
  • Menu 2
    • sub menu 3
    • sub menu 4
      • sub menu 1
+1  A: 

You might want to look at QObject::findChildren, and use it like this:

submenus = mainwindow.menuBar().findChildren(QAction)

Depending on how you construct your menus you might have to use QMenu as a parameter aswell. Also depending on your usage some sub menus could have no parent (depending on how you constructed them or added them to the parent menu) and then findChildren won't find them.

Idan K