We currently have many different ways of accessing platform specific functionality in Qt. Let's try to clean up/unify things a bit in Qt 6.
Non-typed access to platform internals. Private API.
Non-source or binary compatible helper functions to maniplulate QWindow (and a few other classes) in platform specific ways. Implemented via many layers of indirection via QPlatformNativeInterface to end up in the platform plugin.
A kitchen sink / dumping ground for any functionality that didn't fit elsewhere in Qt (at that point). Ends up stale over time, and discourages integrating the concepts in Qt in a cross platform way.
E.g. https://doc.qt.io/qt-5/qtwinextras-overview.html#type-conversion, QPixmap to HBITMAP and back. Similar functions for macOS. Nowadays lives with QImage, as QImage::toNSImage(), etc.
Should just use native APIs. Don't be afraid to mix and match. Qt can't (and shouldn't) do everything, and using Qt with other platform or 3rd party libraries should be possible and easy.
Similar to QtPlatformHeaders
Warning: This class is only available on X11. For querying per-screen information in a portable way, use QDesktopWidget.
Yepp, time to modernize
The "winId" of QOpenGLContext, but via QVariant, resulting in awkward wrappers like QCocoaNativeContext
Should already be possible with winId and fromWinId, and those should Just WorkTM. We don't want wrapper classes with every permutation of QSomePlatformNativeSomeQtFramework, eg QWinNativeQuickItem, QXCBNative3DNode, QWaylandNativeGraphicsViewItem etc etc.
- Type conversions close to their class for easy discoverability
- A single way to tweak QtGui classes in platform specific ways
- Move "solutions" and nice-to-have helper classes to Qt proper as cross platform APIs if possible
- Allow people to use winId and similar through a unified API to integrate with native APIs
- Remove simple single-line wrappers that people should be able to do easily with native APIs themselves
With the class, QImage::toNSImage.
QPlatformWindow, cast to your platform. No source or binary compat. Requires platform plugin to be a library with headers. Shouldn't be a problem. Platform plugin is just thin loading shim. Or not even needed on platforms with only a single platform plugin.
QWindow::toNSView (or winId), fromWinId.