Our application needs to control how windows close pretty carefully- we handle QEvent::close by ignoring it, then doing whatever we feel like we need to do. That is, we take over management of the situation.
-John Weeks WaveMetrics, Inc. > On Oct 30, 2018, at 5:53 AM, Andy <asmalo...@gmail.com> wrote: > > Turns out that if you have a QMainWindow containing a QWindow (e.g. by using > QWidget::createWindowContainer()): > > - if you call QMainWindow::close(), the QWindow receives QEvent::Hide and > does the right thing > - if you click the close button in the title bar, the QWindow receives > QEvent::Close which calls QWindow::destroy() > > This is not what I would expect. Is this by design? > > The QWidget::createWindowContainer docs don't mention this as a limitation. > > I haven't yet found a way around it, so suggestions appreciated. > > --- > Andy Maloney // https://asmaloney.com > twitter ~ @asmaloney > > > On Tue, Oct 30, 2018 at 7:24 AM Andy <asmalo...@gmail.com> wrote: > Setup: > > - two QMainWindows - "main" and "viewer" > - "viewer" uses Qt3D via QWidget::createWindowContainer() > - shortcut "cmd-w" (Qt::ApplicationShortcut) set up to call close() on > "viewer" if it is the activeWindow() > - "viewer" does not have WA_DeleteOnClose set, so the window is only hidden > > Problem: > > - if I close the viewer via the shortcut and reopen it, the 3D view is fine > - if I close it via the close button in the title bar (macOS or Windows) and > reopen it, the 3D view is blank > > Any idea why my 3D view is getting killed in the second case? > > This may be a red-herring, but I've traced both through to > QWidgetPrivate::close_helper() and each is called with a different mode. The > first is called with "CloseWithEvent" and the second with > "CloseWithSpontaneousEvent". Could this be a factor? > > I have another window which uses a QGraphicsView set up exactly the same way > and it works fine, so maybe Qt3D is doing something I'm not expecting based > on a CloseWithSpontaneousEvent? > > Thanks for any ideas/suggestions. > > --- > Andy Maloney // https://asmaloney.com > twitter ~ @asmaloney > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest -John _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest