Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.11.2, 5.12
-
-
51300566ffe2ece2455e1d0479a556c5dbb3bb8e (qt/qtbase/dev)
Description
Generally 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 - i.e. I can show it again and everything is ok
- if you click the close button in the title bar, the QWindow receives QEvent::Close which (might!) call QWindow::destroy()
Tried on macOS 10.12.6 with Qt 5.11.2 and Qt 5.12 from git, and Windows 7 with Qt 5.11.2.
Expectation
For a window containing a QWindow (in a widget), I would expect clicking on the close button in the title bar to do the same thing as calling close().
Example
There are several issues here.
- Run the example
- click "Show Raster"
- this will create and show a window using QRasterWindow & you should see "_RasterContents QPlatformSurfaceEvent(surfaceEventType=SurfaceCreated)"
- click "Close Raster"
- this will close the window by calling "close()"
- click "Show Raster" - this will show it again - all good!
Now:
- click the close button on the Raster window's title bar
- we now get "_RasterContents QPlatformSurfaceEvent(surfaceEventType=SurfaceAboutToBeDestroyed)"? (Problem #1 - why is this happening?)
- but I don't think anything is actually destroyed...
- showing it again works...
Now let's do the same with the 3D example:
- click "Show 3D"
- this will create and show a window using QRasterWindow & you should see "_3DContents QPlatformSurfaceEvent(surfaceEventType=SurfaceCreated)"
- click "Close 3D"
- this will close the window by calling "close()"
- click "Show 3D" - this will show it again - all good!
Now:
- click the close button on the 3D window's title bar
- now we get "_3DContents QPlatformSurfaceEvent(surfaceEventType=SurfaceAboutToBeDestroyed)"
- click "Show 3D"
- contents are gone! (or crashes on Windows?) (Problem #2 - why are my contents gone?)
- There is a slight difference here on macOS between 5.11 and 5.12. With 5.11 I get a white background, with 5.12 I get a grey background.
Bonus problem
With the raster one, (at least on macOS), when the window is shown and I command-tab away and then back, the contents are not updated until I resize the window. (Problem #3 - it should be updated properly)
(I will attach the example code after I have a bug number.)
Attachments
Issue Links
- is duplicated by
-
QTBUG-96286 [Reg 5.9.8 -> ] QWidget loosing contents when using winId() and re-opened
- Closed
- relates to
-
QTBUG-74606 floating QDockWidget with native child widget fails to show() after closing it
- Closed