QAction Group Vs. Vector and Array
Hi,
I am just wondering what is so special about QActionGroup. Why can’t I use arrays? (when I did, I ran into Segmentation Faults) and/or vectors? Is QActionGroup a special class that cannot be initiated in the form of an array?
Also;
- ...
- ActionGroup->addAction(myAction);
- delete myAction;
is “myAction” now part of “ActionGroup” or is it now deleted? Does QActionGroup store action objects?
Thanks!
-Masoug
8 replies
Hi, I am just wondering what is so special about QActionGroup. … Does QActionGroup store action objects? -Masoug
Have you checked the docs for QActionGroup in the Qt Assistant?
- delete myAction;
If you want to remove myAction from the group, you should just use removeAction(myAction). Calling delete will “delete” myAction.
So if I just callwill I still be able to find “myAction” in “ActionGroup”? Or does “ActionGroup” have a copy of “myAction”?
delete myAction;
Most certainly note. QActionGroups holds a pointer to myAction. When myAction is deleted, QActionGroup receives the destroyed() signal from myAction and removes it from it’s internal list.
Having said that, it’s always better/safer to call deleteLater() on QObjects:
- myAction->deleteLater()
You must log in to post a reply. Not a member yet? Register here!




