Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80233

Qt 6 platform APIs revamp

    XMLWordPrintable

Details

    • Platform APIs revamp

    Description

      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.

      What we have

      QPlatformNativeInterface

      Non-typed access to platform internals. Private API.

      QtPlatformHeaders

      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.

      QFooExtras

      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.

      Type conversions

      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.

      Simple (one-line even) wrappers around native APIs

      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.

      Helper functions to maniplulate QWindow and friends

      Similar to QtPlatformHeaders

      QX11Info

      Warning: This class is only available on X11. For querying per-screen information in a portable way, use QDesktopWidget.

      Yepp, time to modernize

      QOpenGLContext's nativeHandle QVariant

      The "winId" of QOpenGLContext, but via QVariant, resulting in awkward wrappers like QCocoaNativeContext

      QMacNativeWidget and QMacCocoaViewContainer

      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.


      What we want

      • 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

      Possible solution

      Type conversions

      With the class, QImage::toNSImage.

      Platform specific manipulation of QWindow and friends

      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.

      Window embedding

      QWindow::toNSView (or winId), fromWinId.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-80233
          # Subject Branch Project Status CR V

          Activity

            People

              vestbo Tor Arne Vestbø
              vestbo Tor Arne Vestbø
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              Tor Arne Vestbø Tor Arne Vestbø
              Votes:
              2 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes