QPlatformIntegration Class

The QPlatformIntegration class is the entry for WindowSystem specific functionality. More...

Header: #include <QPlatformIntegration>

Public Types

enum Capability { ThreadedPixmaps, OpenGL, ThreadedOpenGL, SharedGraphicsCache, BufferQueueingOpenGL, …, ScreenWindowGrabbing }

Public Functions

virtual QPlatformAccessibility *accessibility() const
virtual void beep() const
virtual QPlatformClipboard *clipboard() const
virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const
virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const
virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const
virtual QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const
virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const
virtual void destroy()
virtual QPlatformDrag *drag() const
virtual QPlatformFontDatabase *fontDatabase() const
virtual void initialize()
virtual QPlatformInputContext *inputContext() const
virtual QOpenGLContext::OpenGLModuleType openGLModuleType()
virtual QList<int> possibleKeys(const QKeyEvent *) const
virtual void quit() const
virtual void setApplicationBadge(qint64 number)
virtual void setApplicationIcon(const QIcon &icon) const
virtual void sync()

Detailed Description

\since4.8 \internal \preliminary \ingroup qpa

QPlatformIntegration is the single entry point for windowsystem specific functionality when using the QPA platform. It has factory functions for creating platform specific pixmaps and windows. The class also controls the font subsystem.

QPlatformIntegration is a singleton class which gets instantiated in the QGuiApplication constructor. The QPlatformIntegration instance do not have ownership of objects it creates in functions where the name starts with create. However, functions which don't have a name starting with create acts as accessors to member variables.

It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefore the recommended approach for making new platform plugin is to copy an existing plugin inside the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.

The minimal platform integration is the smallest platform integration it is possible to make, which makes it an ideal starting point for new plugins. For a slightly more advanced plugin, consider reviewing the directfb plugin, or the testlite plugin.

Member Type Documentation

enum QPlatformIntegration::Capability

Capabilities are used to determine specific features of a platform integration

ConstantValueDescription
QPlatformIntegration::ThreadedPixmaps1The platform uses a pixmap implementation that is reentrant and can be used from multiple threads, like the raster paint engine and QImage based pixmaps.
QPlatformIntegration::OpenGL2The platform supports OpenGL
QPlatformIntegration::ThreadedOpenGL3The platform supports using OpenGL outside the GUI thread.
QPlatformIntegration::SharedGraphicsCache4The platform supports a shared graphics cache
QPlatformIntegration::BufferQueueingOpenGL5Deprecated. The OpenGL implementation on the platform will queue up buffers when swapBuffers() is called and block only when its buffer pipeline is full, rather than block immediately.
QPlatformIntegration::MultipleWindows7The platform supports multiple QWindows, i.e. does some kind of compositing either client or server side. Some platforms might only support a single fullscreen window.
QPlatformIntegration::ApplicationState8The platform handles the application state explicitly. This means that QEvent::ApplicationActivate and QEvent::ApplicationDeativate will not be posted automatically. Instead, the platform must handle application state explicitly by using QWindowSystemInterface::handleApplicationStateChanged(). If not set, application state will follow window activation, which is the normal behavior for desktop platforms.
QPlatformIntegration::ForeignWindows9The platform allows creating QWindows which represent native windows created by other processes or by using native libraries.
QPlatformIntegration::NonFullScreenWindows10The platform supports top-level windows which do not fill the screen. The default implementation returns true. Returning false for this will cause all windows, including dialogs and popups, to be resized to fill the screen.
QPlatformIntegration::WindowManagement12The platform is based on a system that performs window management. This includes the typical desktop platforms. Can be set to false on platforms where no window management is available, meaning for example that windows are never repositioned by the window manager. The default implementation returns true.
QPlatformIntegration::AllGLFunctionsQueryable16Deprecated. Used to indicate whether the QOpenGLContext backend provided by the platform is able to return function pointers from getProcAddress() even for standard OpenGL functions, for example OpenGL 1 functions like glClear() or glDrawArrays(). This is important because the OpenGL specifications do not require this ability from the getProcAddress implementations of the windowing system interfaces (EGL, WGL, GLX). The platform plugins may however choose to enhance the behavior in the backend implementation for QOpenGLContext::getProcAddress() and support returning a function pointer also for the standard, non-extension functions. This capability is a prerequisite for dynamic OpenGL loading. Starting with Qt 5.7, the platform plugin is required to have this capability.
QPlatformIntegration::ApplicationIcon17The platform supports setting the application icon. (since 5.5)
QPlatformIntegration::TopStackedNativeChildWindows19The platform supports native child windows via QWindowContainer without having to punch a transparent hole in the backingstore. (since 5.10)
QPlatformIntegration::OpenGLOnRasterSurface20The platform supports making a QOpenGLContext current in combination with a QWindow of type RasterSurface.
QPlatformIntegration::PaintEvents22The platform sends paint events instead of expose events when the window needs repainting. Expose events are only sent when a window is toggled from a non-exposed to exposed state or back.
QPlatformIntegration::RhiBasedRendering23The platform supports one or more of the 3D rendering APIs that Qt Quick and other components can use via the Qt Rendering Hardware Interface. On platforms where it is clear upfront that the platform cannot, or does not want to, support rendering via 3D graphics APIs such as OpenGL, Vulkan, Direct 3D, or Metal, this capability can be reported as false. That in effect means that in modules where there is an alternative, such as Qt Quick with its software backend, an automatic fallback to that alternative may occur, if applicable. The default implementation of hasCapability() returns true.
QPlatformIntegration::ScreenWindowGrabbing24The platform supports grabbing window on screen. On Wayland, this capability can be reported as false. The default implementation of hasCapability() returns true.

Member Function Documentation

[virtual] QPlatformAccessibility *QPlatformIntegration::accessibility() const

Returns the platforms accessibility.

The default implementation returns QPlatformAccessibility which delegates handling of accessibility to accessiblebridge plugins.

[virtual] void QPlatformIntegration::beep() const

\since5.7

Should sound a bell, using the default volume and sound.

See also QApplication::beep().

[virtual] QPlatformClipboard *QPlatformIntegration::clipboard() const

Accessor for the platform integration's clipboard.

Default implementation returns a default QPlatformClipboard.

See also QPlatformClipboard.

[virtual] QPaintEngine *QPlatformIntegration::createImagePaintEngine(QPaintDevice *paintDevice) const

Factory function for QPaintEngine. This function will return 0 if the platform integration does not support creating any paint engine the given paintDevice.

[virtual] QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const

Factory function for QOffscreenSurface. An offscreen surface will typically be implemented with a pixel buffer (pbuffer). If the platform doesn't support offscreen surfaces, an invisible window will be used by QOffscreenSurface instead.

[virtual] QPlatformOpenGLContext *QPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const

Factory function for QPlatformOpenGLContext. The context parameter is a pointer to the context for which a platform-specific context backend needs to be created. Configuration settings like the format, share context and screen have to be taken from this QOpenGLContext and the resulting platform context is expected to be backed by a native context that fulfills these criteria.

If the context has native handles set, no new native context is expected to be created. Instead, the provided handles have to be used. In this case the ownership of the handle must not be taken and the platform implementation is not allowed to destroy the native context. Configuration parameters like the format are also to be ignored. Instead, the platform implementation is responsible for querying the configuriation from the provided native context.

Returns a pointer to a QPlatformOpenGLContext instance or nullptr if the context could not be created.

See also QOpenGLContext.

[virtual] QPlatformSessionManager *QPlatformIntegration::createPlatformSessionManager(const QString &id, const QString &key) const

\since5.2

Factory function for QPlatformSessionManager. The default QPlatformSessionManager provides the same functionality as the QSessionManager.

[virtual] QPlatformSharedGraphicsCache *QPlatformIntegration::createPlatformSharedGraphicsCache(const char *cacheId) const

Factory function for QPlatformSharedGraphicsCache. This function will return 0 if the platform integration does not support any shared graphics cache mechanism for the given cacheId.

[virtual] QPlatformVulkanInstance *QPlatformIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const

Factory function for QPlatformVulkanInstance. The instance parameter is a pointer to the instance for which a platform-specific backend needs to be created.

Returns a pointer to a QPlatformOpenGLContext instance or nullptr if the context could not be created.

\since5.10

See also QVulkanInstance.

[virtual] void QPlatformIntegration::destroy()

Called before the platform integration is deleted. Useful when cleanup relies on virtual functions.

\since5.5

[virtual] QPlatformDrag *QPlatformIntegration::drag() const

Accessor for the platform integration's drag object.

Default implementation returns QSimpleDrag. This class supports only drag and drop operations within the same Qt application.

[virtual] QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const

Accessor for the platform integration's fontdatabase.

Default implementation returns a default QPlatformFontDatabase.

See also QPlatformFontDatabase.

[virtual] void QPlatformIntegration::initialize()

Performs initialization steps that depend on having an event dispatcher available. Called after the event dispatcher has been created.

Tasks that require an event dispatcher, for example creating socket notifiers, cannot be performed in the constructor. Instead, they should be performed here. The default implementation does nothing.

[virtual] QPlatformInputContext *QPlatformIntegration::inputContext() const

Returns the platforms input context.

The default implementation returns nullptr, implying no input method support.

[virtual] QOpenGLContext::OpenGLModuleType QPlatformIntegration::openGLModuleType()

Platform integration function for querying the OpenGL implementation type.

Used only when dynamic OpenGL implementation loading is enabled.

Subclasses should reimplement this function and return a value based on the OpenGL implementation they have chosen to load.

Note: The return value does not indicate or limit the types of contexts that can be created by a given implementation. For example a desktop OpenGL implementation may be capable of creating OpenGL ES-compatible contexts too.

\since5.3

See also QOpenGLContext::openGLModuleType() and QOpenGLContext::isOpenGLES().

[virtual] QList<int> QPlatformIntegration::possibleKeys(const QKeyEvent *) const

Should be used to obtain a list of possible shortcuts for the given key event. Shortcuts should be encoded as int(Qt::Key + Qt::KeyboardModifiers).

One example for more than one possibility is the key combination of Shift+5. That one might trigger a shortcut which is set as "Shift+5" as well as one using %. These combinations depend on the currently set keyboard layout.

Note: This function should be called only from key event handlers.

[virtual] void QPlatformIntegration::quit() const

\since6.0

Asks the platform to terminate the application.

Overrides should ensure there's a callback into the QWSI function handleApplicationTermination so that the quit can be propagated to QtGui and the application.

[virtual] void QPlatformIntegration::setApplicationBadge(qint64 number)

\since6.5

Should set the application's badge to number.

If the number is 0 the badge should be cleared.

See also QGuiApplication::setBadge().

[virtual] void QPlatformIntegration::setApplicationIcon(const QIcon &icon) const

\since5.5

Platform integration function for setting the application icon.

See also QGuiApplication::setWindowIcon().

[virtual] void QPlatformIntegration::sync()

\since5.2

Function to sync the platform integrations state with the window system.

This is often implemented as a roundtrip from the platformintegration to the window system.

This function should not call QWindowSystemInterface::flushWindowSystemEvents() or QCoreApplication::processEvents()