Qt Platform Abstraction

Qt 平台抽象 (QPA) 是 Qt 5 的平台抽象层, 取代了Qt 的嵌入式 Linux 端口和 Qt 4 的平台端口.

QPA 插件是通过子类化各种 QPlatform* 类来实现的. QPA 有几个根类, 例如用于窗口系统集成的 QPlatformIntegrationQPlatformWindow, 更深入的平台主题和集成的 QPlatformTheme. QStyle 不是 QPA 的一部分.

QPA 类没有源代码或二进制兼容性保证, 这意味着平台插件只能保证与其开发所针对的 Qt 版本一起使用. 然而, API 更改只会在次要版本中进行. (5.1, 5.2 等等)

QPA Minimal Plugins

目前还没有编写 QPA 插件的详细教程文档。 但是,Qt 5 附带了两个最小的插件,用于测试和其他特殊目的,您可以将其用作示例: qtbase/src/插件/平台/最小/ qtbase/src/plugins/platforms/minimalegl/ qminimal 插件用于链接到 Qt GUI 的工具,但不需要窗口系统集成(例如,qmlplugindump)。 它还具有诊断支持,可将窗口内容转储到由环境变量确定的图像文件。

目前还没有编写 QPA 插件的详细教程文档. 但是, Qt 5 附带了两个最小的插件, 用于测试和其他特殊目的, 你可以将其用作示例:

  • qtbase/src/plugins/platforms/minimal/
  • qtbase/src/plugins/platforms/minimalegl/

The qminimal 插件用于链接到 Qt GUI 的工具, 但不需要窗口系统集成 (例如, qmlplugindump). 它还具有诊断支持, 可将窗口内容转储到由环境变量确定的图像文件.

Class Overview

  • QPlatformIntegration
    • QAbstractEventDispatcher
    • QPlatformAccessibility
    • QPlatformBackingStore
    • QPlatformClipboard
    • QPlatformCursor
    • QPlatformDrag
    • QPlatformFontDatabase
    • QPlatformGraphicsBuffer
    • QPlatformInputContext
    • QPlatformNativeInterface
    • QPlatformOffscreenSurface
    • QPlatformOpenGLContext
    • QPlatformScreen
    • QPlatformServices
    • QPlatformSharedGraphicsCache
    • QPlatformSurface
    • QPlatformWindow
  • QPlatformTheme

qtbase/src/platformsupport 包含几个辅助类, 用于在类 Unix 系统实现平台插件.

QPA Plugins

下表总结了可用于 QPA 的平台插件:

Plugin NamePlugin Class NameDescription
qandroidQAndroidPlatformIntegrationAndroid support
qbsdfbQBsdFbIntegrationBsdFb support
qcocoaQCocoaIntegrationPluginCocoa support
qdirect2dQWindowsDirect2DIntegrationPluginSimilar to the qwindows plugin, but replaces the raster paint engine with a Direct2D-based paint engine for QPixmap and QBackingStore.
qdirectfbQDirectFbIntegrationPluginDirectFB is centered around surfaces, which are the equivalent of a QPaintDevice.
qeglfsQEglFSIntegrationPluginEGLFS support for embedded Linux devices.
qhaikuQHaikuIntegrationHaiku support
qiosQIOSIntegrationPluginiOS support
qlinuxfbQLinuxFbIntegrationPluginLinuxFB support for embedded Linux devices.
qmirclientQMirClientIntegrationMir client support
qopenwfQOpenWFDIntegrationPluginOpenWF Display support for managing display control hardware.
qqnxQQnxIntegrationPluginQNX support
qvncQVncIntegrationVNC support
qwasmQWasmIntegrationWebAssembly support
qwayland
  • QWaylandIntegrationPlugin
  • QWaylandBrcmEglPlatformIntegrationPlugin
  • QWaylandEglPlatformIntegrationPlugin
  • QWaylandXCompositeEglPlatformIntegrationPlugin
  • QWaylandXCompositeGlxPlatformIntegrationPlugin
Wayland support
qwindowsQWindowsIntegrationPluginWindows support
qwinrtQWinRTIntegrationPluginUniversal Windows Platform (UWP) support

Note: This plugin was originally written for WinRT (Windows Runtime), and is therefore called qwinrt.

qxcbQXcbIntegrationPluginX Window System (X11) support
webglQWebGLIntegrationPluginWebGL support for Qt Quick applications