From bb0e68637d8513d703a32a569be1bb4b2d16fddf Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Thu, 7 Feb 2019 17:28:36 +0100 Subject: [PATCH] avoid widget showing up twice QT5 shows a widget twice when you set a parent at initialization and reset the parent later. This is exactly what happens when a widget is initialized and passed to AddWidget in the gosty app. The solution is to initialize them without a parent and let the AddWidget function taking care of it. --- examples/code_fragments/ui/widget_example.py | 2 +- modules/gui/src/gosty_app.cc | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/examples/code_fragments/ui/widget_example.py b/examples/code_fragments/ui/widget_example.py index 1c996c253..ced1d02fa 100644 --- a/examples/code_fragments/ui/widget_example.py +++ b/examples/code_fragments/ui/widget_example.py @@ -26,7 +26,7 @@ from board import Board panels=gui.GostyApp.Instance().perspective.panels #Create Widget -tetris=Board(panels.qobject) +tetris=Board() #Wrap widget to Qt Widget wid=gui.Widget(tetris) diff --git a/modules/gui/src/gosty_app.cc b/modules/gui/src/gosty_app.cc index ec2a6b14c..de0b008cc 100644 --- a/modules/gui/src/gosty_app.cc +++ b/modules/gui/src/gosty_app.cc @@ -122,17 +122,8 @@ ost::img::gui::DataViewer* GostyApp::CreateDataViewer(const ost::img::ImageHandl } else { - viewer=new ost::img::gui::DataViewer(main_,d,name); - QMdiSubWindow* mdi=new QMdiSubWindow(this->GetPerspective()->GetMainArea()); - mdi->setWindowTitle(name); - mdi->setWidget(viewer); - mdi->setFocusProxy(viewer); - viewer->setAttribute(Qt::WA_DeleteOnClose); - mdi->setAttribute(Qt::WA_DeleteOnClose); - viewer->setParent(mdi); - this->GetPerspective()->GetMainArea()->addSubWindow(mdi); - mdi->showMaximized(); - connect(viewer,SIGNAL(released()),mdi,SLOT(close())); + viewer=new ost::img::gui::DataViewer(NULL,d,name); + this->GetPerspective()->GetMainArea()->AddWidget(name, viewer); } return viewer; -- GitLab