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
-
[quote author="masoug" date="1285381463"]Hi,
I am just wondering what is so special about QActionGroup. ... Does QActionGroup store action objects?
-Masoug[/quote]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.
-
[quote author="chetankjain" date="1285398264"]
If you want to remove myAction from the group, you should just use removeAction(myAction). Calling delete will "delete" myAction.[/quote]So if I just call @delete myAction;@ will I still be able to find "myAction" in "ActionGroup"? Or does "ActionGroup" have a copy of "myAction"?
Thanks!
-Masoug
-
[quote author="masoug" date="1285433909"]So if I just call @delete myAction;@ will I still be able to find "myAction" in "ActionGroup"? Or does "ActionGroup" have a copy of "myAction"?[/quote]
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()@
-
masoug, what is myAction in this case and how have it been inititalized?