Hi,
In a widget of mine, I create a contextmenu like this
QAction* act
= menu.
addAction("menuaction");
act->setStatusTip("fff");
...
QMenu menu(this);
QAction* act = menu.addAction("menuaction");
act->setStatusTip("fff");
...
To copy to clipboard, switch view to plain text mode
But! I realized the statusTip doesnt work. That's because the QAction needs to be a direct child of the QMainWindow containing the statusBar, as far as I can tell. And indeed, if I add act->setParent(my_main_window), then the statusTip works!
But now I am wondering if I leak the QActions. The documentation says "QMenu takes ownership of the returned QAction." But is this ownership expressed in a qobject-child-parent relationship, or does the menu explicitly delete the action?
Does the QMenu still own the QAction when I call setParent(my_main_window)?
As far as I can tell this is indeed the case.
Second question: Is it possible to add a statusTip to a submenu?
QMenu* submenu
= menu.
addMenu("submenue");
QAction* act
= submenu
->addAction
("menuaction");
submenu->setStatusTip("fff"); //doesnt work!
...
QMenu menu(this);
QMenu* submenu = menu.addMenu("submenue");
QAction* act = submenu->addAction("menuaction");
submenu->setStatusTip("fff"); //doesnt work!
...
To copy to clipboard, switch view to plain text mode
It doesnt work, even if I force its parent to my mainwindow (which is not possible bc it messes with the submenues location).
Any way to accomplish this?
Bookmarks