Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
styles-widget-reference.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page style-widget-reference.html
6
\title Widget Style Reference
7
\brief The style elements, state flags, and style options that each Qt
8
widget uses.
9
10
This reference describes how Qt's widgets use the style. Use it when you
11
implement a style, to see which elements you need to draw and which
12
information the widgets pass to you, or when you write a style-aware widget
13
or a delegate, to draw the same elements that Qt's widgets draw.
14
15
The reference is split into three pages:
16
17
\list
18
\li \l{Styling Buttons and Input Widgets}: push buttons, checkboxes and
19
radio buttons, tool buttons, combo boxes, spin boxes, sliders, scroll
20
bars, and progress bars.
21
\li \l{Styling Containers and Windows}: tab widgets, group boxes, splitters,
22
toolboxes, toolbars, dock widgets, title bars, size grips, and rubber
23
bands.
24
\li \l{Styling Menus and Item Views}: menus, menu bars, item view headers,
25
tree branch indicators, and item view items.
26
\endlist
27
28
\section1 What the reference lists for each widget
29
30
\list
31
\li \b{The element tree.} The style elements that the widget draws, in
32
drawing order. A nested element is drawn by the element above it in
33
\l QCommonStyle. Next to each element, the reference names the sub
34
element rectangles, subcontrols, and pixel metrics that \l QCommonStyle
35
uses when it draws that element. Your own style can structure its
36
drawing differently; only the elements the widget calls are fixed.
37
\li \b{A screenshot.} The widget in the Fusion style, with the bounding
38
rectangles of the elements outlined. The colors only tell the rectangles
39
apart. Rectangles that coincide are drawn one pixel inside each other.
40
\li \b{The state flags.} The \l QStyle::StateFlag values that the widget
41
sets on its style option, in addition to the common flags that
42
\l QStyleOption::initFrom() sets.
43
\li \b{The style option members.} The members of the widget's
44
\l QStyleOption subclass and what the widget stores in them.
45
\endlist
46
47
The common state flags and members are described in
48
\l{How a Style Draws a Widget#Common state flags and members}{How a Style
49
Draws a Widget}.
50
51
\section1 What the reference leaves out
52
53
The widgets also use the style for calculations that aren't part of drawing.
54
They ask for their size hints with \l{QStyle::}{sizeFromContents()}, for
55
their frame widths and margins with \l{QStyle::}{pixelMetric()}, and for the
56
position of their subelements with \l{QStyle::}{subElementRect()}. The
57
reference names the contents types and the pixel metrics that each widget
58
queries but doesn't describe how the built-in styles calculate them. How a
59
style performs those calculations is up to the style. Qt doesn't impose a
60
structure. When in doubt, read the \l QCommonStyle implementation.
61
62
\sa {Styles and Style Aware Widgets}, {How a Style Draws a Widget}, QStyle,
63
QStyleOption
64
*/
qtbase
src
widgets
doc
src
widgets-and-layouts
styles-widget-reference.qdoc
Generated on
for Qt by
1.16.1