[英]Freeing allocated memory with Qt toolbars and actions
Do I need to free Qt toolbars and actions? 我是否需要释放Qt工具栏和操作?
I created them this way 我用这种方式创造了它们
QToolBar *tb = new QToolBar(this);
tb->setWindowTitle(tr("Edit Actions"));
addToolBar(tb);
QAction *a;
a = actionUndo = new QAction(...ecc..);
are these deallocated automatically or do I need to free them up? 这些是自动解除分配还是我需要释放它们?
In short, yes they are deallocated automatically as part of the Qt framework as it appears you are properly passing in the parent (ie this in your case). 简而言之,是的,它们作为Qt框架的一部分自动解除分配,因为它看起来正确地传递了父级(即在您的情况下这是)。 Also, in the case of the QToolBar, calling addToolBar will cause it to be 're-parented' if it didn't already have a correct parent.
此外,在QToolBar的情况下,如果调用addToolBar没有正确的父级,则调用addToolBar将使其成为“重新父级”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.