Priority: P1: Critical
Affects Version/s: 6.0.0, 6.1.0
Environment:macOS 10.15, macOS 11.0
Qt 6.0 and Qt 6.1
Commits:40878e75176880e95398604d9e63be2138cc642b (qt/qtbase/dev) 4e58b19b0c1d3d46808b5cc42e147ac7da8a7e21 (qt/qtbase/6.1)
I'm having an issue with Qt 6.0 and Qt 6.1 which doesn't happen with Qt 5.15 and earlier.
On a Retina screen, when I embed a Qt window inside a non-Qt host app AND uses QOpenGLWidget, my Qt window is rendered with a device pixel ratio of 1 (instead of 2), while the non-Qt host app around it is still rendered at full Retina resolution (device pixel ratio of 2).
I've rooted down the issue to this commit : https://github.com/qt/qtbase/commit/1fc7ca091b3fdda52381a383318a3a752ec21132
My interpretation is that while standalone Qt applications are fine with this commit, Qt app embedded within other host apps still need to account for different environments.
And indeed if I apply the reverse of this commit to Qt 6.1.0, I get back the full Retina resolution on my embedded Qt app which uses OpenGL.
In addition to that I had to make two slight changes to this reverse commit :
in qtbase/src/plugins/platforms/cocoa/qnsview_drawing.mm I had to force
to always return true (which is safe because 10.14 is now the minimum Qt requirement), because otherwise it could be mislead by a host app built with an older macOS SDK (which doesn't matter in this case, as it's my Qt app SDK that matters). Wrongly returning "false" in this case led to a freeze of the embedded Qt app when trying to display new windows.
And although it was never called in my case, I also made the same change to qtbase/src/plugins/platforms/cocoa/qcocoaintegration.mm in
should always return false.
With this reverse commits+2 slights changes I have my OpenGL Qt app running fine both in standalone and embedded mode, on Mojave, Catalina and Big Sur.
For the sake of clarity I'm attaching the modified files:
6.1.0 -> reverse commit (8 files) -> slight modification in qnsview_drawing.mm and qcocoaintegration.mm