Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QWindowsIntegration Class Reference

QPlatformIntegration implementation for Windows. More...

#include <qwindowsintegration.h>

+ Inheritance diagram for QWindowsIntegration:
+ Collaboration diagram for QWindowsIntegration:

Public Types

enum  Options {
  FontDatabaseFreeType = 0x1 , FontDatabaseNative = 0x2 , DisableArb = 0x4 , NoNativeDialogs = 0x8 ,
  XpNativeDialogs = 0x10 , DontPassOsMouseEventsSynthesizedFromTouch = 0x20 , DontUseDirectWriteFonts = QWindowsFontDatabase::DontUseDirectWriteFonts , DontUseColorFonts = QWindowsFontDatabase::DontUseColorFonts ,
  AlwaysUseNativeMenus = 0x100 , NoNativeMenus = 0x200 , DontUseWMPointer = 0x400 , DetectAltGrModifier = 0x800 ,
  RtlEnabled = 0x1000 , FontDatabaseDirectWrite = 0x2000
}
 
- Public Types inherited from QPlatformIntegration
enum  Capability {
  ThreadedPixmaps = 1 , OpenGL , ThreadedOpenGL , SharedGraphicsCache ,
  BufferQueueingOpenGL , WindowMasks , MultipleWindows , ApplicationState ,
  ForeignWindows , NonFullScreenWindows , NativeWidgets , WindowManagement ,
  WindowActivation , SyncState , RasterGLSurface , AllGLFunctionsQueryable ,
  ApplicationIcon , SwitchableWidgetComposition , TopStackedNativeChildWindows , OpenGLOnRasterSurface ,
  MaximizeUsingFullscreenGeometry , PaintEvents , RhiBasedRendering , ScreenWindowGrabbing
}
 Capabilities are used to determine specific features of a platform integration. More...
 
enum  StyleHint {
  CursorFlashTime , KeyboardInputInterval , MouseDoubleClickInterval , StartDragDistance ,
  StartDragTime , KeyboardAutoRepeatRate , ShowIsFullScreen , PasswordMaskDelay ,
  FontSmoothingGamma , StartDragVelocity , UseRtlExtensions , PasswordMaskCharacter ,
  SetFocusOnTouchRelease , ShowIsMaximized , MousePressAndHoldInterval , TabFocusBehavior ,
  ReplayMousePressOutsidePopup , ItemViewActivateItemOnSingleClick , UiEffects , WheelScrollLines ,
  ShowShortcutsInContextMenus , MouseQuickSelectionThreshold , MouseDoubleClickDistance , FlickStartDistance ,
  FlickMaximumVelocity , FlickDeceleration , UnderlineShortcut
}
 

Public Member Functions

 QWindowsIntegration (const QStringList &paramList)
 
 ~QWindowsIntegration () override
 
bool hasCapability (QPlatformIntegration::Capability cap) const override
 
QPlatformWindowcreatePlatformWindow (QWindow *window) const override
 Factory function for QPlatformWindow.
 
QPlatformWindowcreateForeignWindow (QWindow *window, WId nativeHandle) const override
 
QPlatformOpenGLContextcreatePlatformOpenGLContext (QOpenGLContext *context) const override
 Factory function for QPlatformOpenGLContext.
 
QOpenGLContext::OpenGLModuleType openGLModuleType () override
 Platform integration function for querying the OpenGL implementation type.
 
HMODULE openGLModuleHandle () const override
 
QOpenGLContextcreateOpenGLContext (HGLRC context, HWND window, QOpenGLContext *shareContext) const override
 
QAbstractEventDispatchercreateEventDispatcher () const override
 Factory function for the GUI event dispatcher.
 
void initialize () override
 Performs initialization steps that depend on having an event dispatcher available.
 
QPlatformInputContextinputContext () const override
 Returns the platforms input context.
 
QPlatformFontDatabasefontDatabase () const override
 Accessor for the platform integration's fontdatabase.
 
QStringList themeNames () const override
 
QPlatformThemecreatePlatformTheme (const QString &name) const override
 
QPlatformServicesservices () const override
 
QVariant styleHint (StyleHint hint) const override
 
Qt::KeyboardModifiers queryKeyboardModifiers () const override
 
QList< int > possibleKeys (const QKeyEvent *e) const override
 Should be used to obtain a list of possible shortcuts for the given key event.
 
unsigned options () const
 
void beep () const override
 
void setApplicationBadge (qint64 number) override
 
void setApplicationBadge (const QImage &image)
 
void updateApplicationBadge ()
 
- Public Member Functions inherited from QPlatformIntegration
virtual ~QPlatformIntegration ()
 
virtual bool hasCapability (Capability cap) const
 
virtual QPlatformPixmapcreatePlatformPixmap (QPlatformPixmap::PixelType type) const
 Factory function for QPlatformPixmap.
 
virtual QPlatformWindowcreatePlatformWindow (QWindow *window) const =0
 Factory function for QPlatformWindow.
 
virtual QPlatformWindowcreateForeignWindow (QWindow *, WId) const
 
virtual QPlatformBackingStorecreatePlatformBackingStore (QWindow *window) const =0
 Factory function for QPlatformBackingStore.
 
virtual QPlatformOpenGLContextcreatePlatformOpenGLContext (QOpenGLContext *context) const
 Factory function for QPlatformOpenGLContext.
 
virtual QPlatformSharedGraphicsCachecreatePlatformSharedGraphicsCache (const char *cacheId) const
 Factory function for QPlatformSharedGraphicsCache.
 
virtual QPaintEnginecreateImagePaintEngine (QPaintDevice *paintDevice) const
 Factory function for QPaintEngine.
 
virtual QAbstractEventDispatchercreateEventDispatcher () const =0
 Factory function for the GUI event dispatcher.
 
virtual void initialize ()
 Performs initialization steps that depend on having an event dispatcher available.
 
virtual void destroy ()
 Called before the platform integration is deleted.
 
virtual QPlatformFontDatabasefontDatabase () const
 Accessor for the platform integration's fontdatabase.
 
virtual QPlatformClipboardclipboard () const
 Accessor for the platform integration's clipboard.
 
virtual QPlatformInputContextinputContext () const
 Returns the platforms input context.
 
virtual QPlatformNativeInterfacenativeInterface () const
 
virtual QPlatformServicesservices () const
 
virtual QVariant styleHint (StyleHint hint) const
 
virtual Qt::WindowState defaultWindowState (Qt::WindowFlags) const
 
virtual Qt::KeyboardModifiers queryKeyboardModifiers () const
 
virtual QList< int > possibleKeys (const QKeyEvent *) const
 Should be used to obtain a list of possible shortcuts for the given key event.
 
virtual QStringList themeNames () const
 
virtual QPlatformThemecreatePlatformTheme (const QString &name) const
 
virtual QPlatformOffscreenSurfacecreatePlatformOffscreenSurface (QOffscreenSurface *surface) const
 Factory function for QOffscreenSurface.
 
virtual QPlatformSessionManagercreatePlatformSessionManager (const QString &id, const QString &key) const
 
virtual void sync ()
 
virtual QOpenGLContext::OpenGLModuleType openGLModuleType ()
 Platform integration function for querying the OpenGL implementation type.
 
virtual void setApplicationIcon (const QIcon &icon) const
 
virtual void setApplicationBadge (qint64 number)
 
virtual void beep () const
 
virtual void quit () const
 
template<auto func, typename... Args>
auto call (Args... args)
 
- Public Member Functions inherited from QWindowsApplication
void setTouchWindowTouchType (TouchWindowTouchTypes type) override
 
TouchWindowTouchTypes touchWindowTouchType () const override
 
WindowActivationBehavior windowActivationBehavior () const override
 
void setWindowActivationBehavior (WindowActivationBehavior behavior) override
 
void setHasBorderInFullScreenDefault (bool border) override
 
bool isTabletMode () const override
 
bool isWinTabEnabled () const override
 
bool setWinTabEnabled (bool enabled) override
 
bool isDarkMode () const override
 
DarkModeHandling darkModeHandling () const override
 
void setDarkModeHandling (DarkModeHandling handling) override
 
void registerMime (QWindowsMimeConverter *mime) override
 
void unregisterMime (QWindowsMimeConverter *mime) override
 
int registerMimeType (const QString &mime) override
 
HWND createMessageWindow (const QString &classNameTemplate, const QString &windowName, QFunctionPointer eventProc=nullptr) const override
 
bool asyncExpose () const override
 
void setAsyncExpose (bool value) override
 
QVariant gpu () const override
 
QVariant gpuList () const override
 
void populateLightSystemPalette (QPalette &palette) const override
 

Static Public Member Functions

static QWindowsStaticOpenGLContextstaticOpenGLContext ()
 
static QWindowsIntegrationinstance ()
 

Protected Member Functions

virtual QWindowsWindowcreatePlatformWindowHelper (QWindow *window, const QWindowsWindowData &) const
 
- Protected Member Functions inherited from QPlatformIntegration
 QPlatformIntegration ()=default
 

Detailed Description

QPlatformIntegration implementation for Windows.

The platform plugin should run on Desktop Windows from Windows XP onwards and Windows Embedded.

It should compile with: \list

  • Microsoft Visual Studio 2013 or later (using the Microsoft Windows SDK, (Q_CC_MSVC).
  • Stock \l{http://mingw.org/}{MinGW} (Q_CC_MINGW). This version ships with headers that are missing a lot of WinAPI.
  • MinGW distributions using GCC 4.7 or higher and a recent MinGW-w64 runtime API, such as \l{http://tdm-gcc.tdragon.net/}{TDM-GCC}, or \l{http://mingwbuilds.sourceforge.net/}{MinGW-builds} (Q_CC_MINGW and __MINGW64_VERSION_MAJOR indicating the version). MinGW-w64 provides more complete headers (compared to stock MinGW from mingw.org), including a considerable part of the Windows SDK. \endlist

Definition at line 25 of file qwindowsintegration.h.

Member Enumeration Documentation

◆ Options

Enumerator
FontDatabaseFreeType 
FontDatabaseNative 
DisableArb 
NoNativeDialogs 
XpNativeDialogs 
DontPassOsMouseEventsSynthesizedFromTouch 
DontUseDirectWriteFonts 
DontUseColorFonts 
AlwaysUseNativeMenus 
NoNativeMenus 
DontUseWMPointer 
DetectAltGrModifier 
RtlEnabled 
FontDatabaseDirectWrite 

Definition at line 33 of file qwindowsintegration.h.

Constructor & Destructor Documentation

◆ QWindowsIntegration()

QWindowsIntegration::QWindowsIntegration ( const QStringList paramList)
explicit

Definition at line 265 of file qwindowsintegration.cpp.

References DetectAltGrModifier, QWindowsScreenManager::initialize(), QWindowsIntegrationPrivate::m_context, QWindowsIntegrationPrivate::m_options, QWindowsIntegrationPrivate::parseOptions(), QWindowsContext::screenManager(), and QWindowsContext::setDetectAltGrModifier().

+ Here is the call graph for this function:

◆ ~QWindowsIntegration()

QWindowsIntegration::~QWindowsIntegration ( )
override

Definition at line 277 of file qwindowsintegration.cpp.

Member Function Documentation

◆ beep()

void QWindowsIntegration::beep ( ) const
overridevirtual
Since
5.7

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

See also
QApplication::beep()

Reimplemented from QPlatformIntegration.

Definition at line 637 of file qwindowsintegration.cpp.

◆ createEventDispatcher()

QAbstractEventDispatcher * QWindowsIntegration::createEventDispatcher ( ) const
overridevirtual

Factory function for the GUI event dispatcher.

The platform plugin should create and return a QAbstractEventDispatcher subclass when this function is called.

If the platform plugin for some reason creates the event dispatcher outside of this function (for example in the constructor), it needs to handle the case where this function is never called, ensuring that the event dispatcher is still deleted at some point (typically in the destructor).

Note that the platform plugin should never explicitly set the event dispatcher itself, using QCoreApplication::setEventDispatcher(), but let QCoreApplication decide when and which event dispatcher to create.

Since
5.2

Implements QPlatformIntegration.

Definition at line 615 of file qwindowsintegration.cpp.

◆ createForeignWindow()

QPlatformWindow * QWindowsIntegration::createForeignWindow ( QWindow window,
WId  nativeHandle 
) const
overridevirtual

Reimplemented from QPlatformIntegration.

Definition at line 367 of file qwindowsintegration.cpp.

References Qt::dec(), Qt::hex(), Qt::noshowbase(), qCDebug, qWarning, screen, Qt::showbase(), and window().

+ Here is the call graph for this function:

◆ createOpenGLContext()

QOpenGLContext * QWindowsIntegration::createOpenGLContext ( HGLRC  context,
HWND  window,
QOpenGLContext shareContext 
) const
override

Definition at line 475 of file qwindowsintegration.cpp.

References context, QWindowsStaticOpenGLContext::createContext(), QOpenGLContextPrivate::get(), staticOpenGLContext(), and window().

+ Here is the call graph for this function:

◆ createPlatformOpenGLContext()

QPlatformOpenGLContext * QWindowsIntegration::createPlatformOpenGLContext ( QOpenGLContext context) const
overridevirtual

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

Reimplemented from QPlatformIntegration.

Definition at line 445 of file qwindowsintegration.cpp.

References context, QWindowsStaticOpenGLContext::createContext(), qCDebug, and staticOpenGLContext().

+ Here is the call graph for this function:

◆ createPlatformTheme()

QPlatformTheme * QWindowsIntegration::createPlatformTheme ( const QString name) const
overridevirtual

Reimplemented from QPlatformIntegration.

Definition at line 625 of file qwindowsintegration.cpp.

References QPlatformIntegration::createPlatformTheme(), and QWindowsTheme::name.

+ Here is the call graph for this function:

◆ createPlatformWindow()

QPlatformWindow * QWindowsIntegration::createPlatformWindow ( QWindow window) const
overridevirtual

Factory function for QPlatformWindow.

The window parameter is a pointer to the window which the QPlatformWindow is supposed to be created for.

All windows have to have a QPlatformWindow, and it will be created on-demand when the QWindow is made visible for the first time, or explicitly through calling QWindow::create().

In the constructor, of the QPlatformWindow, the window flags, state, title and geometry of the window should be applied to the underlying window. If the resulting flags or state differs, the resulting values should be set on the window using QWindow::setWindowFlags() or QWindow::setWindowState(), respectively.

See also
QPlatformWindow, QPlatformWindowFormat
createPlatformBackingStore()

Implements QPlatformIntegration.

Definition at line 320 of file qwindowsintegration.cpp.

References QWindowsWindowData::create(), createPlatformWindowHelper(), QWindowsWindowData::customMargins, Qt::dec(), Qt::Desktop, QWindowsWindow::DisableNonClientScaling, QWindowsWindowData::flags, QWindowsWindow::formatWindowTitle(), Qt::FramelessWindowHint, QWindowsWindowData::fullFrameMargins, QWindowsWindowData::geometry, Qt::hex(), QWindowsWindowData::hwnd, QVariant::isValid(), QWindowsMenuBar::menuBarOf(), Qt::noshowbase(), QWindowsGeometryHint::positionIncludesFrame(), Q_ASSERT, Q_UNLIKELY, qCDebug, QWindowsContext::shouldHaveNonClientDpiScaling(), Qt::showbase(), QHighDpi::toNativeLocalPosition(), QHighDpi::toNativePixels(), and window().

+ Here is the call graph for this function:

◆ createPlatformWindowHelper()

QWindowsWindow * QWindowsIntegration::createPlatformWindowHelper ( QWindow window,
const QWindowsWindowData data 
) const
protectedvirtual

Reimplemented in QWindowsDirect2DIntegration.

Definition at line 387 of file qwindowsintegration.cpp.

References window().

Referenced by createPlatformWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fontDatabase()

QPlatformFontDatabase * QWindowsIntegration::fontDatabase ( ) const
overridevirtual

Accessor for the platform integration's fontdatabase.

Default implementation returns a default QPlatformFontDatabase.

See also
QPlatformFontDatabase

Reimplemented from QPlatformIntegration.

Definition at line 507 of file qwindowsintegration.cpp.

References FontDatabaseDirectWrite, FontDatabaseFreeType, QWindowsIntegrationPrivate::m_fontDatabase, and QWindowsIntegrationPrivate::m_options.

◆ hasCapability()

◆ initialize()

void QWindowsIntegration::initialize ( )
overridevirtual

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.

Reimplemented from QPlatformIntegration.

Definition at line 282 of file qwindowsintegration.cpp.

References QPlatformInputContextFactory::create(), QString::isNull(), QWindowsIntegrationPrivate::m_inputContext, QPlatformInputContextFactory::requested(), and QScopedPointer< T, Cleanup >::reset().

+ Here is the call graph for this function:

◆ inputContext()

QPlatformInputContext * QWindowsIntegration::inputContext ( ) const
overridevirtual

Returns the platforms input context.

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

Reimplemented from QPlatformIntegration.

Definition at line 591 of file qwindowsintegration.cpp.

References QScopedPointer< T, Cleanup >::data(), and QWindowsIntegrationPrivate::m_inputContext.

+ Here is the call graph for this function:

◆ instance()

◆ openGLModuleHandle()

HMODULE QWindowsIntegration::openGLModuleHandle ( ) const
override

Definition at line 467 of file qwindowsintegration.cpp.

References QWindowsStaticOpenGLContext::moduleHandle(), and staticOpenGLContext().

+ Here is the call graph for this function:

◆ openGLModuleType()

QOpenGLContext::OpenGLModuleType QWindowsIntegration::openGLModuleType ( )
overridevirtual

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.
See also
QOpenGLContext::openGLModuleType(), QOpenGLContext::isOpenGLES()
Since
5.3

Reimplemented from QPlatformIntegration.

Definition at line 456 of file qwindowsintegration.cpp.

References QOpenGLContext::LibGL, QWindowsStaticOpenGLContext::moduleType(), and staticOpenGLContext().

+ Here is the call graph for this function:

◆ options()

unsigned QWindowsIntegration::options ( ) const

Definition at line 603 of file qwindowsintegration.cpp.

References QWindowsIntegrationPrivate::m_options.

Referenced by QWindowsGLContext::QWindowsGLContext(), doUseNativeMenus(), WindowCreationData::fromWindow(), and QWindowsMouseHandler::translateMouseEvent().

+ Here is the caller graph for this function:

◆ possibleKeys()

QList< int > QWindowsIntegration::possibleKeys ( const QKeyEvent ) const
overridevirtual

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.

Reimplemented from QPlatformIntegration.

Definition at line 573 of file qwindowsintegration.cpp.

References e, QWindowsIntegrationPrivate::m_context, and QWindowsContext::possibleKeys().

+ Here is the call graph for this function:

◆ queryKeyboardModifiers()

Qt::KeyboardModifiers QWindowsIntegration::queryKeyboardModifiers ( ) const
overridevirtual

Reimplemented from QPlatformIntegration.

Definition at line 568 of file qwindowsintegration.cpp.

References QWindowsKeyMapper::queryKeyboardModifiers().

+ Here is the call graph for this function:

◆ services()

QPlatformServices * QWindowsIntegration::services ( ) const
overridevirtual

Reimplemented from QPlatformIntegration.

Definition at line 632 of file qwindowsintegration.cpp.

References QWindowsIntegrationPrivate::m_services.

◆ setApplicationBadge() [1/2]

void QWindowsIntegration::setApplicationBadge ( const QImage image)

Definition at line 745 of file qwindowsintegration.cpp.

References QGuiApplication::topLevelWindows().

+ Here is the call graph for this function:

◆ setApplicationBadge() [2/2]

void QWindowsIntegration::setApplicationBadge ( qint64  number)
overridevirtual
Since
6.5

Should set the application's badge to number.

If the number is 0 the badge should be cleared.

See also
QGuiApplication::setBadge()

Reimplemented from QPlatformIntegration.

Definition at line 642 of file qwindowsintegration.cpp.

References QRect::adjust(), Qt::AlignCenter, QPainter::Antialiasing, Qt::black, QOperatingSystemVersion::current(), QFont::DemiBold, QPainter::drawEllipse(), QPainter::drawText(), QPainter::end(), QPainter::font(), font, QImage::Format_ARGB32_Premultiplied, QWindowsContext::isDarkMode(), QWindowsApplication::isDarkMode(), QColor::isValid(), QFont::Medium, Qt::NoPen, number, QString::number(), painter, qApp, qCeil(), qMax(), qt_win_hasPackageIdentity(), QColor::setAlphaF(), setApplicationBadge(), QPainter::setBrush(), QPainter::setFont(), QPainter::setPen(), QFont::setPixelSize(), QPainter::setRenderHint(), settings, QFont::setWeight(), text, QPainter::TextAntialiasing, QPainter::translate(), Qt::transparent, Qt::white, and QOperatingSystemVersion::Windows11.

Referenced by setApplicationBadge(), and updateApplicationBadge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ staticOpenGLContext()

QWindowsStaticOpenGLContext * QWindowsIntegration::staticOpenGLContext ( )
static

Definition at line 494 of file qwindowsintegration.cpp.

References QWindowsStaticOpenGLContext::create(), d, QScopedPointer< T, Cleanup >::data(), instance(), and lock.

Referenced by createOpenGLContext(), createPlatformOpenGLContext(), hasCapability(), QWindowsWindow::invalidateSurface(), QWindowsNativeInterface::nativeResourceForIntegration(), openGLModuleHandle(), openGLModuleType(), and QWindowsWindow::surface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ styleHint()

◆ themeNames()

QStringList QWindowsIntegration::themeNames ( ) const
overridevirtual

Reimplemented from QPlatformIntegration.

Definition at line 620 of file qwindowsintegration.cpp.

References QWindowsTheme::name.

◆ updateApplicationBadge()

void QWindowsIntegration::updateApplicationBadge ( )

Definition at line 782 of file qwindowsintegration.cpp.

References setApplicationBadge().

Referenced by QWindowsContext::windowsProc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: