Ingo Förster
asked on
QT Cancel MdiChild creation
In my app I use an mdiArea as central widget. Inside this I create different Childs.
Like:
The MdiChildDiskInfo is a
The MdiChildDiskInfo is created with
I tried to stop creating the MdiChildDiskInfo with this->close() while the MdiChildDiskInfo is created. The close event is fired.
But always an empty QSubWindow is created. Means child has always an object.
I expect that the child is null when I add this->close() to the constructor. Special in case of Qt::WA_DeleteOnClose. But child is always an object. It looks that the MdiChildDiskInfo is always create also if I say close it.
Finally I want that
MdiChildDiskInfo *child = new MdiChildDiskInfo(this,strD riveName);
will return null to child.
Like:
MdiChildDiskInfo *child = new MdiChildDiskInfo(this,strDriveName);
if(child){
mdiArea->addSubWindow(child);
child->showMaximized();
}
The MdiChildDiskInfo is a
class MdiChildDiskInfo : public MdiChildBase
that is basing on
class MdiChildBase : public QMainWindow
The MdiChildDiskInfo is created with
MdiChildDiskInfo::MdiChildDiskInfo(QWidget* parent, const QString &device)
:strBurnDrive(device){
setAttribute(Qt::WA_DeleteOnClose);
this->close();
}
I tried to stop creating the MdiChildDiskInfo with this->close() while the MdiChildDiskInfo is created. The close event is fired.
But always an empty QSubWindow is created. Means child has always an object.
I expect that the child is null when I add this->close() to the constructor. Special in case of Qt::WA_DeleteOnClose. But child is always an object. It looks that the MdiChildDiskInfo is always create also if I say close it.
Finally I want that
MdiChildDiskInfo *child = new MdiChildDiskInfo(this,strD
will return null to child.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I added a var to the MIDChild class. If an error happens I set this to false and do not add the child to the mdiArea. Lets see if this will cause memleaks. I hope not.
Open in new window