On this page

Styles and Style Aware Widgets

Styles (classes that inherit QStyle) draw on behalf of widgets and encapsulate the look and feel of a GUI. QStyle is an abstract base class. Qt's built-in widgets use it for nearly all of their drawing, so they look exactly like the equivalent native widgets.

Qt comes with a selection of built-in styles. The windows and fusion styles are part of the Qt Widgets module. The platform styles, such as windows11 on Windows and macos on macOS, are plugins that are available on their platform only. QStyleFactory lists the styles that are available at runtime and creates them by name. QApplication::setStyle() makes a style the application style, and users can select a style with the -style command-line option.

A QStyle implementation is the way to give a production application its own look. StyleKit provides one, QStyleKitStyle, that reads a QML description of the design. For when to use a style, StyleKit, or a style sheet, see Styling Approaches for Qt Widgets.

Customizing a style

To change selected aspects of an existing style, inherit QProxyStyle and reimplement the virtual functions that draw or measure the elements you want to change. A proxy style wraps another style and forwards everything you don't reimplement to it.

You can name the base style explicitly or leave it unspecified. An explicit base style gives you full control and suits customizations that depend on a particular style's behavior. Without a base style, the proxy wraps the application style, so your customization applies on top of whatever the platform provides.

The QStyle class documentation shows a proxy style that replaces the arrows of a spin box.

Implementing a style

QCommonStyle provides a convenient base for full style implementations. It implements the behavior that all of Qt's styles share, such as the layout of subelements and the size calculations, and leaves the drawing to you. Inherit QCommonStyle and reimplement the drawing functions, together with the pixel metrics, subelement rectangles, and style hints that differ from the common defaults. Qt's built-in styles aren't part of the public API and can't serve as base classes; wrap them with QProxyStyle instead.

Implementing a full style is an involved task. The following pages describe how the style API works, trace how a widget is drawn from its paint event to the style, and list the elements, states, and options that each widget uses:

The elements the widgets draw are the same in every style, so you can also use the reference when you write a style-aware widget or a delegate.

Classes for widget styling

Use these classes to customize an application's appearance.

QColor

Colors based on RGB, HSV or CMYK values

QColorSpace

Color space abstraction

QColorTransform

Transformation between color spaces

QCommonStyle

Encapsulates the common Look and Feel of a GUI

QCursor

Mouse cursor with an arbitrary shape

QFont

Specifies a query for a font used for drawing text

QFontDatabase

Information about the fonts available in the underlying window system

QFontInfo

General information about fonts

QGraphicsAnchor

Represents an anchor between two items in a QGraphicsAnchorLayout

QGraphicsAnchorLayout

Layout where one can anchor widgets together in Graphics View

QPalette

Contains color groups for each widget state

QStyle

Abstract base class that encapsulates the look and feel of a GUI

QStyleFactory

Creates QStyle objects

QStyleHintReturn

Style hints that return more than basic data types

QStyleHintReturnMask

Style hints that return a QRegion

QStyleHintReturnVariant

Style hints that return a QVariant

QStyleKitStyle

Applies a Qt Labs StyleKit style to Qt Widgets

QStyleOption

Stores the parameters used by QStyle functions

QStylePainter

Convenience class for drawing QStyle elements inside a widget

See also QStyle, QProxyStyle, QCommonStyle, QStylePainter, QStyleOption, and Styling Approaches for Qt Widgets.

© 2026 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.