From 663263c124339db432cd5596b87462343096dd83 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 21 Mar 2016 14:17:18 +0100 Subject: QWidget::create(): Mark parameter window as ignored. Remove parameter from QWidgetPrivate::createWinId(), add a warning and fixme comments. Update the documentation to point the users to QWindow::fromWinId() and QWidget::createWindowContainer(). Task-number: QTBUG-33079 Task-number: QTBUG-51853 Change-Id: I03ae922b31bb46a411889cc0260ea14a4d933492 Reviewed-by: Marc Mutz --- src/widgets/kernel/qwidget.cpp | 30 ++++++++++++++---------------- src/widgets/kernel/qwidget_p.h | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6fdd5d3d0e..c57ca41815 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1243,11 +1243,14 @@ void QWidgetPrivate::createRecursively() } - +// ### fixme: Qt 6: Remove parameter window from QWidget::create() /*! - Creates a new widget window if \a window is 0, otherwise sets the - widget's window to \a window. + Creates a new widget window. + + The parameter \a window is ignored in Qt 5. Please use + QWindow::fromWinId() to create a QWindow wrapping a foreign + window and pass it to QWidget::createWindowContainer() instead. Initializes the window (sets the geometry etc.) if \a initializeWindow is true. If \a initializeWindow is false, no @@ -1260,11 +1263,15 @@ void QWidgetPrivate::createRecursively() The QWidget constructor calls create(0,true,true) to create a window for this widget. + + \sa createWindowContainer(), QWindow::fromWinId() */ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) { Q_D(QWidget); + if (Q_UNLIKELY(window)) + qWarning("QWidget::create(): Parameter 'window' does not have any effect."); if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId()) return; @@ -1288,7 +1295,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) // We're about to create a native child widget that doesn't have a native parent; // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors // attribute is set. - d->createWinId(window); + d->createWinId(); // Nothing more to do. Q_ASSERT(testAttribute(Qt::WA_WState_Created)); Q_ASSERT(internalWinId()); @@ -2520,13 +2527,12 @@ WId QWidget::winId() const return data->winid; } - -void QWidgetPrivate::createWinId(WId winid) +void QWidgetPrivate::createWinId() { Q_Q(QWidget); #ifdef ALIEN_DEBUG - qDebug() << "QWidgetPrivate::createWinId for" << q << winid; + qDebug() << "QWidgetPrivate::createWinId for" << q; #endif const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { @@ -2543,15 +2549,7 @@ void QWidgetPrivate::createWinId(WId winid) QWidget *w = qobject_cast(pd->children.at(i)); if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created) || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) { - if (w!=q) { - w->create(); - } else { - w->create(winid); - // if the window has already been created, we - // need to raise it to its proper stacking position - if (winid) - w->raise(); - } + w->create(); } } } else { diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index a5c7aa5815..9d4bdc7f89 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -333,7 +333,7 @@ public: void init(QWidget *desktopWidget, Qt::WindowFlags f); void create_sys(WId window, bool initializeWindow, bool destroyOldWindow); void createRecursively(); - void createWinId(WId id = 0); + void createWinId(); void createTLExtra(); void createExtra(); -- cgit v1.2.3