use QObject parent logic when setting parent for QWindow

(cherry picked from commit 2be9fdb4b58accea4078654efed49a50acf6c74d)
This commit is contained in:
Jørgen Lind 2011-04-27 10:12:17 +02:00 committed by Samuel Rødal
parent 54ab99d5e2
commit d8784df713
2 changed files with 10 additions and 3 deletions

View File

@ -83,8 +83,11 @@ public:
};
QWindow::QWindow(QWindow *parent)
: QObject(*new QWindowPrivate(), parent)
: QObject(*new QWindowPrivate())
{
if (parent) {
setParent(parent);
}
}
QWindow::~QWindow()
@ -131,9 +134,12 @@ WId QWindow::winId() const
return d->platformWindow->winId();
}
void QWindow::setParent(const QWindow *parent)
void QWindow::setParent(QWindow *parent)
{
Q_D(QWindow);
if (QObject::parent() == parent) {
return;
}
//How should we support lazy init when setting parent
if (!parent->d_func()->platformWindow) {
const_cast<QWindow *>(parent)->create();
@ -143,6 +149,7 @@ void QWindow::setParent(const QWindow *parent)
create();
}
d->platformWindow->setParent(parent->d_func()->platformWindow);
QObject::setParent(parent);
}
void QWindow::setWindowFormat(const QWindowFormat &format)

View File

@ -92,7 +92,7 @@ public:
void create();
WId winId() const;
void setParent(const QWindow *parent);
void setParent(QWindow *parent);
void setWindowFormat(const QWindowFormat &format);
QWindowFormat requestedWindowFormat() const;