ghorwin
13th April 2007, 17:14
Hi there,
I created a QObject based class passing another QObject as parent. Now I want to use the QObject somewhere else and need to reparent it. So far I use
// first
MyClass * c1 = new MyClass(containerWidget);
containerWidget->widgetList.append(c1);
// later
MyClass * c2 = containerWidget->widgetList->takeAt(14);
c2->setParent(newContainerWidget);
Is that enough? What happens, if containerWidget gets destroyed before newContainerWidget? Will it delete my class instance as well or does the setParent() call sever the parent-children connection completely?
Bye
I created a QObject based class passing another QObject as parent. Now I want to use the QObject somewhere else and need to reparent it. So far I use
// first
MyClass * c1 = new MyClass(containerWidget);
containerWidget->widgetList.append(c1);
// later
MyClass * c2 = containerWidget->widgetList->takeAt(14);
c2->setParent(newContainerWidget);
Is that enough? What happens, if containerWidget gets destroyed before newContainerWidget? Will it delete my class instance as well or does the setParent() call sever the parent-children connection completely?
Bye