KDAB / KDDockWidgets

KDAB's Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets
Other
762 stars 164 forks source link

`setTitle` on floating-changed doesn't work #468

Closed bbc131 closed 7 months ago

bbc131 commented 7 months ago

I want to modify a dockwidgets title depending on the floating-state.

Therefore I was going to suggest to add an isFloatingChanged signal to the QtWidgets::DockWidget class as done here https://github.com/bbc131/KDDockWidgets/commit/883754a1568a690fde85005182f22b7f50e7f9ff.

But it seems, that there is a problem with the underlying signal.

To reproduce with the dockwidgets example, apply the commit above and add the following code to MyMainWindow::newDockWidget as shown here

    ...

    connect(dock, &KDDockWidgets::QtWidgets::DockWidget::isFloatingChanged, this, [dock](bool is_floating) {
        auto name = dock->uniqueName();
        auto floating = QString(is_floating ? "FLOATING" : "NOT-FLOATING");
        qDebug() << "isFloatingChanged: '" + name + "' -> " + floating;
        dock->setTitle(name + QString(": ") + floating);
    });

    count++;
    return dock;
}

Now run the example, undock any DockWidget and then dock it onto any other DockWidget, such that they appear tabbed. The title in the TabBar is wrong, it still shows the "FLOATING" text. The TitleBar's text is correct. See the following screenshot, where I docked #2 onto #0.

image

iamsergio commented 7 months ago

Thanks for the easy repro. Fixed now.

bbc131 commented 7 months ago

Only now I checked this and still found wrong titles displayed, when you use the "(un)dock" button. To reproduce, use the same code example as before and then press the "(un)dock" button on any floating DockWidget to dock it into the MainWindow. (I tested it on current state of main branch, commit 763c8a795c.)

While playing with this, it seems that some other things might affect the behavior, without being able to narrow it down precisely. It seems to be easier to reproduce, if there are all the DockWidgets in the example hidden except of two. Further, sometimes it seems, that the problem occurs only if the DockWidget was set floating using the "(un)dock".

iamsergio commented 7 months ago

fixed 2nd issue + test, please test again.

bbc131 commented 7 months ago

I guess you fixed a different problem... I extended the test, by the exact use case I meant, this fails for me. https://github.com/bbc131/KDDockWidgets/commit/9814de36931bbd0b36ab4d9dafb0a0c4fd26bfda