Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockWidgets in 2nd MainWindow within first MainWindow do not show when dockWidgets are toggled #360

Open
dlinenbe opened this issue May 14, 2023 · 1 comment
Assignees

Comments

@dlinenbe
Copy link

// The 2nd MainWindow within first MainWindow does not show its dockWidgets when toggled

using namespace KDDockWidgets;

DockWidget *createDockWidget(MainWindow mainWindow, QMenu mainWindowMenu, const QString &label, const QStringList affinities = {})
{
auto dockWidget = new DockWidget(label);
dockWidget->setAffinities(affinities);
QLabel *l = new QLabel(label);
dockWidget->setWidget(l);
mainWindow->addDockWidget(dockWidget, Location::Location_OnTop);
mainWindowMenu->addAction(dockWidget->toggleAction());
return dockWidget;
}

int main(int argc, char **argv)
{
QApplication app(argc, argv);

MainWindow * mainWindow = new MainWindow("mainWindow");
QMenu *mainWindowMenu = mainWindow->menuBar()->addMenu("Toggle1");
createDockWidget(mainWindow, mainWindowMenu, "L1");
createDockWidget(mainWindow, mainWindowMenu, "L2");

auto mainWindowDockWidget3 = new DockWidget("mainWindowInMainWindow");
MainWindow*  mainWindow2 = new MainWindow("mainWindow2");
QMenu *mainWindowMenu2 = mainWindow2->menuBar()->addMenu("Toggle2");
const QStringList affinities { "DwInDw" };
mainWindow2->setAffinities(affinities);
mainWindowDockWidget3->setWidget(mainWindow2);
mainWindow->addDockWidget(mainWindowDockWidget3, Location_OnRight);

createDockWidget(mainWindow2, mainWindowMenu2, "L3", affinities);
createDockWidget(mainWindow2, mainWindowMenu2, "L4", affinities);

// Note - widgets show correctly on initialization,
// but when Toggle1/mainWindowInMainWindow is toggled, the dock widgets L3 & L4
// are not shown
mainWindowMenu->addAction(mainWindowDockWidget3->toggleAction());  

mainWindow->resize(800, 800);
mainWindow->show();
return app.exec();

}

@dlinenbe
Copy link
Author

dlinenbe commented May 14, 2023

Above code compiles and runs correctly on initialization - but note the key comment:

// Note - widgets show correctly on initialization,
// but when Toggle1/mainWindowInMainWindow is toggled, the dock widgets L3 & L4
// are not shown

@iamsergio iamsergio self-assigned this May 15, 2023
iamsergio added a commit that referenced this issue Sep 18, 2023
Issue #326 is in the way, so added a workaround.
When #326 is fixed, this test will test both code paths.
iamsergio added a commit that referenced this issue Sep 18, 2023
The bug happens with normal non-nested main windows as well.
Closing a main window and then reshowing it will show with
all its dock widgets hidden
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants