QtWin Namespace

The QtWin namespace contains miscellaneous Windows-specific functions. More...

Header: #include <QtWin>
qmake: QT += winextras

Types

enum HBitmapFormat { HBitmapNoAlpha, HBitmapPremultipliedAlpha, HBitmapAlpha }
enum WindowFlip3DPolicy { FlipDefault, FlipExcludeAbove, FlipExcludeBelow }

Functions

QColor colorizationColor(bool *opaqueBlend = nullptr)
HBITMAP createMask(const QBitmap &bitmap)
void disableBlurBehindWindow(QWindow *window)
void disableBlurBehindWindow(QWidget *window)
void enableBlurBehindWindow(QWindow *window, const QRegion &region)
void enableBlurBehindWindow(QWindow *window)
void enableBlurBehindWindow(QWidget *window, const QRegion &region)
void enableBlurBehindWindow(QWidget *window)
QString errorStringFromHresult(int hresult)
void extendFrameIntoClientArea(QWindow *window, int left, int top, int right, int bottom)
void extendFrameIntoClientArea(QWindow *window, const QMargins &margins)
void extendFrameIntoClientArea(QWidget *window, const QMargins &margins)
void extendFrameIntoClientArea(QWidget *window, int left, int top, int right, int bottom)
QPixmap fromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format = HBitmapNoAlpha)
QPixmap fromHICON(HICON icon)
QRegion fromHRGN(HRGN hrgn)
QImage imageFromHBITMAP(int hdc, HBITMAP bitmap, int width, int height)
QImage imageFromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format = HBitmapNoAlpha)
HBITMAP imageToHBITMAP(const QImage &image, QtWin::HBitmapFormat format = HBitmapNoAlpha)
bool isCompositionEnabled()
bool isCompositionOpaque()
bool isWindowExcludedFromPeek(QWindow *window)
bool isWindowExcludedFromPeek(QWidget *window)
bool isWindowPeekDisallowed(QWindow *window)
bool isWindowPeekDisallowed(QWidget *window)
void markFullscreenWindow(QWindow *window, bool fullscreen = true)
void markFullscreenWindow(QWidget *window, bool fullscreen = true)
QColor realColorizationColor()
void resetExtendedFrame(QWindow *window)
void resetExtendedFrame(QWidget *window)
void setCompositionEnabled(bool enabled)
void setCurrentProcessExplicitAppUserModelID(const QString &id)
void setWindowDisallowPeek(QWindow *window, bool disallow)
void setWindowDisallowPeek(QWidget *window, bool disallow)
void setWindowExcludedFromPeek(QWindow *window, bool exclude)
void setWindowExcludedFromPeek(QWidget *window, bool exclude)
void setWindowFlip3DPolicy(QWindow *window, QtWin::WindowFlip3DPolicy policy)
void setWindowFlip3DPolicy(QWidget *window, QtWin::WindowFlip3DPolicy policy)
QString stringFromHresult(int hresult)
void taskbarActivateTab(QWindow *window)
void taskbarActivateTab(QWidget *window)
void taskbarActivateTabAlt(QWindow *window)
void taskbarActivateTabAlt(QWidget *window)
void taskbarAddTab(QWindow *window)
void taskbarAddTab(QWidget *window)
void taskbarDeleteTab(QWindow *window)
void taskbarDeleteTab(QWidget *window)
HBITMAP toHBITMAP(const QPixmap &p, QtWin::HBitmapFormat format = HBitmapNoAlpha)
HICON toHICON(const QPixmap &p)
HRGN toHRGN(const QRegion &region)
QtWin::WindowFlip3DPolicy windowFlip3DPolicy(QWindow *window)
QtWin::WindowFlip3DPolicy windowFlip3DPolicy(QWidget *window)

Detailed Description

The QtWin namespace contains miscellaneous Windows-specific functions.

Type Documentation

enum QtWin::HBitmapFormat

This enum defines how the conversion between HBITMAP and QPixmap is performed.

ConstantValueDescription
QtWin::HBitmapNoAlpha0The alpha channel is ignored and always treated as being set to fully opaque. This is preferred if the HBITMAP is used with standard GDI calls, such as BitBlt().
QtWin::HBitmapPremultipliedAlpha1The HBITMAP is treated as having an alpha channel and premultiplied colors. This is preferred if the HBITMAP is accessed through the AlphaBlend() GDI function.
QtWin::HBitmapAlpha2The HBITMAP is treated as having a plain alpha channel. This is the preferred format if the HBITMAP is going to be used as an application icon or a systray icon.

This enum was introduced or modified in Qt 5.2.

See also fromHBITMAP() and toHBITMAP().

enum QtWin::WindowFlip3DPolicy

This enum type specifies the Flip3D window policy.

ConstantValueDescription
QtWin::FlipDefault0Let the OS decide whether to include the window in the Flip3D rendering.
QtWin::FlipExcludeAbove2Exclude the window from Flip3D and display it above the Flip3D rendering.
QtWin::FlipExcludeBelow1Exclude the window from Flip3D and display it below the Flip3D rendering.

This enum was introduced or modified in Qt 5.2.

See also setWindowFlip3DPolicy().

Function Documentation

QColor QtWin::colorizationColor(bool *opaqueBlend = nullptr)

Returns the DWM colorization color. After the function returns, the optional opaqueBlend will contain true if the color is an opaque blend and false otherwise.

This function was introduced in Qt 5.2.

HBITMAP QtWin::createMask(const QBitmap &bitmap)

Creates a HBITMAP equivalent of the QBitmap bitmap.

It is the caller's responsibility to free the HBITMAP data after use.

This function was introduced in Qt 5.2.

See also toHBITMAP().

void QtWin::disableBlurBehindWindow(QWindow *window)

Disables the previously enabled blur effect for the specified window.

This function was introduced in Qt 5.2.

See also enableBlurBehindWindow().

void QtWin::disableBlurBehindWindow(QWidget *window)

This function overloads QtWin::disableBlurBehindWindow().

This function was introduced in Qt 5.2.

void QtWin::enableBlurBehindWindow(QWindow *window, const QRegion &region)

Enables the blur effect for the specified region of the specified window.

This function was introduced in Qt 5.2.

See also disableBlurBehindWindow().

void QtWin::enableBlurBehindWindow(QWindow *window)

Enables the blur effect for the specified window.

This function was introduced in Qt 5.2.

See also disableBlurBehindWindow().

void QtWin::enableBlurBehindWindow(QWidget *window, const QRegion &region)

This function overloads QtWin::enableBlurBehindWindow().

This function was introduced in Qt 5.2.

void QtWin::enableBlurBehindWindow(QWidget *window)

This function overloads QtWin::enableBlurBehindWindow().

This function was introduced in Qt 5.2.

QString QtWin::errorStringFromHresult(int hresult)

Returns the code name of the hresult error id specified (usually the name of the WinAPI macro) or an empty string if the message is unknown.

This function was introduced in Qt 5.2.

void QtWin::extendFrameIntoClientArea(QWindow *window, int left, int top, int right, int bottom)

Extends the glass frame into the client area of the specified window using the left, top, right, and bottom margin values.

Pass -1 as values for any of the four margins to fully extend the frame, creating a sheet of glass effect.

If you want the extended frame to act like a standard window border, you should handle that yourself.

Note: If window is a QWidget handle, set the Qt::WA_NoSystemBackground attribute for your widget.

This function was introduced in Qt 5.2.

See also resetExtendedFrame().

void QtWin::extendFrameIntoClientArea(QWindow *window, const QMargins &margins)

This function overloads QtWin::extendFrameIntoClientArea().

Extends the glass frame into the client area of the specified window using the specified margins.

This function was introduced in Qt 5.2.

void QtWin::extendFrameIntoClientArea(QWidget *window, const QMargins &margins)

This function overloads QtWin::extendFrameIntoClientArea().

Convenience overload that allows passing frame sizes in a margins structure.

This function was introduced in Qt 5.2.

void QtWin::extendFrameIntoClientArea(QWidget *window, int left, int top, int right, int bottom)

This function overloads QtWin::extendFrameIntoClientArea().

This function was introduced in Qt 5.2.

QPixmap QtWin::fromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format = HBitmapNoAlpha)

Returns a QPixmap that is equivalent to the given bitmap. The conversion is based on the specified format.

This function was introduced in Qt 5.2.

See also toHBITMAP().

QPixmap QtWin::fromHICON(HICON icon)

Returns a QPixmap that is equivalent to the given icon.

This function was introduced in Qt 5.2.

See also toHICON().

QRegion QtWin::fromHRGN(HRGN hrgn)

Returns a QRegion that is equivalent to the given hrgn.

This function was introduced in Qt 5.2.

QImage QtWin::imageFromHBITMAP(int hdc, HBITMAP bitmap, int width, int height)

Returns a QImage that is equivalent to the given bitmap. The conversion is based on the specified HDC context hdc using the specified width and height.

This function was introduced in Qt 5.2.

See also toHBITMAP().

QImage QtWin::imageFromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format = HBitmapNoAlpha)

Returns a QImage that is equivalent to the given bitmap. The conversion is based on the specified format.

This function was introduced in Qt 5.12.

See also imageToHBITMAP().

HBITMAP QtWin::imageToHBITMAP(const QImage &image, QtWin::HBitmapFormat format = HBitmapNoAlpha)

Creates a HBITMAP equivalent of the QImage image, based on the given format. Returns the HBITMAP handle.

It is the caller's responsibility to free the HBITMAP data after use.

This function was introduced in Qt 5.12.

See also imageFromHBITMAP().

bool QtWin::isCompositionEnabled()

Returns the DWM composition state.

This function was introduced in Qt 5.2.

bool QtWin::isCompositionOpaque()

Returns whether the colorization color is an opaque blend.

This function was introduced in Qt 5.2.

bool QtWin::isWindowExcludedFromPeek(QWindow *window)

Returns true if the specified window is excluded from Aero Peek.

This function was introduced in Qt 5.2.

bool QtWin::isWindowExcludedFromPeek(QWidget *window)

This function overloads QtWin::isWindowExcludedFromPeek().

This function was introduced in Qt 5.2.

bool QtWin::isWindowPeekDisallowed(QWindow *window)

Returns true if Aero Peek is disallowed on the thumbnail of the specified window.

This function was introduced in Qt 5.2.

bool QtWin::isWindowPeekDisallowed(QWidget *window)

This function overloads QtWin::isWindowPeekDisallowed().

This function was introduced in Qt 5.2.

void QtWin::markFullscreenWindow(QWindow *window, bool fullscreen = true)

Marks the specified window as running in the full-screen mode if fullscreen is true, so that the shell handles it correctly. Otherwise, removes the mark.

Note: You do not usually need to call this function, because the Windows taskbar always tries to determine whether a window is running in the full-screen mode.

This function was introduced in Qt 5.2.

void QtWin::markFullscreenWindow(QWidget *window, bool fullscreen = true)

This function overloads QtWin::markFullscreenWindow().

This function was introduced in Qt 5.2.

QColor QtWin::realColorizationColor()

Returns the real colorization color, set by the user, using an undocumented registry key. The API-based function getColorizationColor() returns an alpha-blended color which often turns out a semitransparent gray rather than something similar to what is chosen by the user.

This function was introduced in Qt 5.2.

See also colorizationColor().

void QtWin::resetExtendedFrame(QWindow *window)

Resets the glass frame and restores the window attributes.

This convenience function calls extendFrameIntoClientArea() with margins set to 0.

Note: You must unset the Qt::WA_NoSystemBackground attribute for extendFrameIntoClientArea() to work.

This function was introduced in Qt 5.2.

See also extendFrameIntoClientArea().

void QtWin::resetExtendedFrame(QWidget *window)

This function overloads QtWin::resetExtendedFrame().

This function was introduced in Qt 5.2.

void QtWin::setCompositionEnabled(bool enabled)

Sets whether the Windows Desktop composition is enabled.

Note: The underlying function was declared deprecated as of Windows 8 and takes no effect.

This function was introduced in Qt 5.2.

See also isCompositionEnabled().

void QtWin::setCurrentProcessExplicitAppUserModelID(const QString &id)

Sets the Application User Model ID id.

For more information, see Application User Model IDs.

This function was introduced in Qt 5.2.

void QtWin::setWindowDisallowPeek(QWindow *window, bool disallow)

Disables Aero Peek for the specified window when hovering over the taskbar thumbnail of the window with the mouse pointer if disallow is true; otherwise allows it.

The default is false.

This function was introduced in Qt 5.2.

void QtWin::setWindowDisallowPeek(QWidget *window, bool disallow)

This function overloads QtWin::setWindowDisallowPeek().

This function was introduced in Qt 5.2.

void QtWin::setWindowExcludedFromPeek(QWindow *window, bool exclude)

Excludes the specified window from Aero Peek if exclude is true.

This function was introduced in Qt 5.2.

See also isWindowExcludedFromPeek().

void QtWin::setWindowExcludedFromPeek(QWidget *window, bool exclude)

This function overloads QtWin::setWindowExcludedFromPeek().

This function was introduced in Qt 5.2.

void QtWin::setWindowFlip3DPolicy(QWindow *window, QtWin::WindowFlip3DPolicy policy)

Sets the Flip3D policy policy for the specified window.

This function was introduced in Qt 5.2.

See also windowFlip3DPolicy().

void QtWin::setWindowFlip3DPolicy(QWidget *window, QtWin::WindowFlip3DPolicy policy)

This function overloads QtWin::setWindowFlip3DPolicy().

This function was introduced in Qt 5.2.

QString QtWin::stringFromHresult(int hresult)

Returns a message string that explains the hresult error id specified or an empty string if the explanation cannot be found.

This function was introduced in Qt 5.2.

void QtWin::taskbarActivateTab(QWindow *window)

Activates an item on the taskbar without activating the window itself.

This function was introduced in Qt 5.2.

void QtWin::taskbarActivateTab(QWidget *window)

This function overloads QtWin::taskbarActivateTab().

This function was introduced in Qt 5.2.

void QtWin::taskbarActivateTabAlt(QWindow *window)

Marks the item that represents the specified window on the taskbar as active, but does not activate it visually.

This function was introduced in Qt 5.2.

void QtWin::taskbarActivateTabAlt(QWidget *window)

This function overloads QtWin::taskbarActivateTabAlt().

This function was introduced in Qt 5.2.

void QtWin::taskbarAddTab(QWindow *window)

Adds an item for the specified window to the taskbar.

This function was introduced in Qt 5.2.

void QtWin::taskbarAddTab(QWidget *window)

This function overloads QtWin::taskbarAddTab().

This function was introduced in Qt 5.2.

void QtWin::taskbarDeleteTab(QWindow *window)

Removes the specified window from the taskbar.

This function was introduced in Qt 5.2.

void QtWin::taskbarDeleteTab(QWidget *window)

This function overloads QtWin::taskbarDeleteTab().

This function was introduced in Qt 5.2.

HBITMAP QtWin::toHBITMAP(const QPixmap &p, QtWin::HBitmapFormat format = HBitmapNoAlpha)

Creates a HBITMAP equivalent of the QPixmap p, based on the given format. Returns the HBITMAP handle.

It is the caller's responsibility to free the HBITMAP data after use.

This function was introduced in Qt 5.2.

See also fromHBITMAP().

HICON QtWin::toHICON(const QPixmap &p)

Creates a HICON equivalent of the QPixmap p. Returns the HICON handle.

It is the caller's responsibility to free the HICON data after use.

This function was introduced in Qt 5.2.

See also fromHICON().

HRGN QtWin::toHRGN(const QRegion &region)

Returns a HRGN that is equivalent to the given region.

This function was introduced in Qt 5.2.

QtWin::WindowFlip3DPolicy QtWin::windowFlip3DPolicy(QWindow *window)

Returns the current Flip3D policy for the specified window.

This function was introduced in Qt 5.2.

See also setWindowFlip3DPolicy().

QtWin::WindowFlip3DPolicy QtWin::windowFlip3DPolicy(QWidget *window)

This function overloads QtWin::windowFlip3DPolicy().

This function was introduced in Qt 5.2.

© 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.