Sort Qt4 QMenu Items

I use QT4 and dynamically add entries to QMenu. Can I sort entries in QMenu without deleting and creating a new one?

I initially thought that there is a function to insert in a specific place so that I can sort by insert, but I could not find it.

+5
source share
2 answers

After adding, I do not think you can reorder. Although you create, although you can use the QWidget :: insertAction method to place it exactly where you want.

void QWidget::insertAction ( QAction * before, QAction * action )

Otherwise, you can use QWidget :: addActions . Create your action list and sort it before adding it to QMenu.

void QWidget::addActions ( QList<QAction *> actions )
+6
+1

All Articles