[Interest] Calling QMainWindow::close() vs. clicking on close button in title bar

Andy asmaloney at gmail.com
Tue Oct 30 12:24:59 CET 2018


- 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


- 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 <https://twitter.com/asmaloney>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181030/4ed20503/attachment.html>

More information about the Interest mailing list