diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2023-05-16 10:40:13 +0200 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2023-06-07 18:46:56 +0200 |
commit | c153066baaa88718ed45b68230d81285eb436d3d (patch) | |
tree | 4adaf029862085737da16d697a943dee5b3d6247 /src/widgets/widgets/qdockwidget.cpp | |
parent | 5a2474b2dd0472948c53b16c4bf566db489dcfb9 (diff) |
QDockWidget: Propagate window title when re-docking
When a floating dockwidget's title changes, it is rendered as a
window title. When the title changes while floating, the change will be
reverted to the pre-change title when the dockwidget is docked again.
This patch explicitly propagates the window title, if it has been
programmatically changed while the dock widget is floating.
It adds test functionality in tst_QDockWidget::floatingTabs().
Fixes: QTBUG-113591
Pick-to: 6.6 6.5
Change-Id: I96fa69fb27ad1a85f4ea9ce44c0a22290259fca6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/widgets/qdockwidget.cpp')
-rw-r--r-- | src/widgets/widgets/qdockwidget.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index c952c8d4fd..5b9704228b 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1186,10 +1186,10 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect return; // this dockwidget can't be redocked } - bool wasFloating = q->isFloating(); + const bool wasFloating = q->isFloating(); if (wasFloating) // Prevent repetitive unplugging from nested invocations (QTBUG-42818) unplug = false; - bool hidden = q->isHidden(); + const bool hidden = q->isHidden(); if (q->isVisible()) q->hide(); @@ -1497,8 +1497,14 @@ void QDockWidget::changeEvent(QEvent *event) QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); switch (event->type()) { - case QEvent::ModifiedChange: case QEvent::WindowTitleChange: + if (isFloating() && windowHandle() && d->topData()) { + // From QWidget::setWindowTitle(): Propagate window title without signal emission + d->topData()->caption = windowHandle()->title(); + d->setWindowTitle_helper(windowHandle()->title()); + } + Q_FALLTHROUGH(); + case QEvent::ModifiedChange: update(layout->titleArea()); #ifndef QT_NO_ACTION d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this); |