I'm using Qt5 and I am trying to do this:
setCentralWidget(wid);
...
setCentralWidget(nullptr); // i don't want it to do deleteLater() for my wid variable
...
setCentralWidget(wid);
The problem is that, when I call setCentralWidget(nullptr)
, it does deleteLater()
for my wid
variable.
So, I found a way to use setCentralWidget()
without deleting the wid
variable:
Q_D(QMainWindow);
d->layout->setCentralWidget(nullptr);
But the question is: How to use private headers or widgets or whatever? I mean, I don't have access to QMainWindowPrivate
or QMainWindowLayout
, because they are private. So is there a way to access them?
CodePudding user response:
OP's issue is caused by using setCentralWidget(nullptr);
.