Unsolved QMainWindow::createPopupMenu() shuffles when a menu is checked
-
This post is deleted! -
Do you have a custom model behind the data? Looks like a sorting happens.
-
Sort of, I updated my image above, I removed the custom model and it still behaves the same.
-
Can you create a minimal, compilable example so we can see what you're doing?
-
This is the gist of what I'm doing:
QMenu *ViewFrame::createPopupMenu() { QMenu *pMenu = QMainWindow::createPopupMenu(); do { if (!pMenu) break; QList<QAction*> liActions = pMenu->actions(); APopupMenu *pNewMenu = new APopupMenu(liActions, this); pMenu = pNewMenu; } while (false); return pMenu; }
SPopupMenu.cpp
APopupMenu::APopupMenu(QList<QAction*> liActions, QWidget *parent : QMenu(parent) { for (auto& iter : liActions) { if (!iter) continue; addAction(iter); } }
And when DockWidget is created I used this
ADockWidget::ADockWidget(const QString &title, QWidget *parent , Qt::WindowFlags flags ) : QDockWidget(title, parent, flags) { do { QAction *pAction = toggleViewAction(); if(!pAction) break; pAction->setData((qulonglong)this); QObject::connect(pAction, &QAction::triggered, this, &ADockWidget::DoSomething); } while(false); }
-
@Kita said in QMainWindow::createPopupMenu() shuffles when a menu is checked:
do { if (!pMenu) break; QList<QAction*> liActions = pMenu->actions(); APopupMenu *pNewMenu = new APopupMenu(liActions, this); pMenu = pNewMenu; } while (false);
What should this do? It runs exactly once, same for other really strang do .. while(false) loops.
We need a fully compilable example to reproduce it on our system.