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
qstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qstyle.h"
6#include "qapplication.h"
7#include "qpainter.h"
8#include "qwidget.h"
9#include "qbitmap.h"
10#include "qpixmapcache.h"
11#include "qset.h"
12#include "qstyleoption.h"
13#include "private/qstyle_p.h"
14#include "private/qstylehelper_p.h"
15#include "private/qguiapplication_p.h"
16#include <qpa/qplatformtheme.h>
17#ifndef QT_NO_DEBUG
18#include "qdebug.h"
19#endif
20#include <QtCore/q20utility.h>
21
22#include <limits.h>
23#include <algorithm>
24
26
27static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType);
28
29static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)
30{
31 if (!controls)
32 return 0;
33
34 // optimization: exactly one bit is set
35 if (qPopulationCount(uint(controls)) == 1) {
36 array[0] = QSizePolicy::ControlType(uint(controls));
37 return 1;
38 }
39
40 int count = 0;
41 for (int i = 0; i < MaxBits; ++i) {
42 if (uint bit = (controls & (0x1 << i)))
43 array[count++] = QSizePolicy::ControlType(bit);
44 }
45 return count;
46}
47
48/*!
49 \page qwidget-styling.html
50 \title Styling
51
52 Qt's built-in widgets use the QStyle class to perform nearly all
53 of their drawing. QStyle is an abstract base class that
54 encapsulates the look and feel of a GUI, and can be used to make
55 the widgets look exactly like the equivalent native widgets or to
56 give the widgets a custom look.
57
58 Qt provides a set of QStyle implementations that match the native
59 look of the platforms it supports. The \c windows and \c fusion
60 styles are built into the Qt Widgets module; the platform styles,
61 such as \c windows11 and \c macos, are loaded as plugins.
62 QStyleFactory lists the styles that are available at runtime.
63 Applications can also provide their own styles, either linked in or
64 as plugins.
65
66 Most functions for drawing style elements take four arguments:
67
68 \list
69 \li an enum value specifying which graphical element to draw
70 \li a QStyleOption object specifying how and where to render that element
71 \li a QPainter object that should be used to draw the element
72 \li a QWidget object on which the drawing is performed (optional)
73 \endlist
74
75 The style gets all the information it needs to render the
76 graphical element from the QStyleOption class. The widget is
77 passed as the last argument in case the style needs it to perform
78 special effects (such as animated default buttons on \macos),
79 but it isn't mandatory. In fact, QStyle can be used to draw on any
80 paint device (not just widgets), in which case the widget argument
81 is a zero pointer.
82
83 \image paintsystem-stylepainter.png
84 {Diagram showing QStylePainter inherits from QPainter}
85
86 The paint system also provides the QStylePainter class inheriting
87 from QPainter. QStylePainter is a convenience class for drawing
88 QStyle elements inside a widget, and extends QPainter with a set
89 of high-level drawing functions implemented on top of QStyle's
90 API. The advantage of using QStylePainter is that the parameter
91 lists get considerably shorter.
92
93 \table 100%
94 \row
95 \li \inlineimage paintsystem-icon.png {Icon used in Qt}
96 \li \b QIcon
97
98 The QIcon class provides scalable icons in different modes and states.
99
100 QIcon can generate pixmaps reflecting an icon's state, mode and
101 size. These pixmaps are generated from the set of pixmaps
102 made available to the icon, and are used by Qt widgets to show an
103 icon representing a particular action.
104
105 The rendering of a QIcon object is handled by the QIconEngine
106 class. Each icon has a corresponding icon engine that is
107 responsible for drawing the icon with a requested size, mode and
108 state.
109
110 \endtable
111
112 For more information about widget styling and appearance, see
113 \l{Styles and Style Aware Widgets} and
114 \l{Styling Approaches for Qt Widgets}.
115*/
116
117/*!
118 \class QStyle
119 \brief The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
120
121 \ingroup appearance
122 \inmodule QtWidgets
123
124 Qt contains a set of QStyle implementations that match the look of
125 the platforms it supports. The \c windows and \c fusion styles are
126 built into the Qt Widgets module. The platform styles are style
127 plugins: \c windows11, which follows the Windows 11 Fluent design, and
128 \c windowsvista on Windows, \c macos on \macos, and \c android on
129 Android. QStyleFactory lists the styles that are available at runtime
130 and creates them by name.
131
132 Qt's built-in widgets use QStyle to perform nearly all of their
133 drawing, ensuring that they look exactly like the equivalent
134 native widgets. The following images show the same form in the
135 \c windows11, \c windowsvista, and \c windows styles on Windows, and in
136 the \c fusion and \c macos styles.
137
138 \table
139 \row
140 \li \image styles/gallery-windows11.webp
141 {Form with text field, combo box, spin box, slider,
142 checkbox, progress bar, and buttons in the Windows 11 style}
143 \caption Windows 11
144 \li \image styles/gallery-windowsvista.webp
145 {Form with text field, combo box, spin box, slider,
146 checkbox, progress bar, and buttons in the Windows Vista style}
147 \caption Windows Vista
148 \li \image styles/gallery-windows.webp
149 {Form with text field, combo box, spin box, slider,
150 checkbox, progress bar, and buttons in the Windows style}
151 \caption Windows
152 \row
153 \li \image styles/gallery-fusion-light.webp
154 {Form with text field, combo box, spin box, slider,
155 checkbox, progress bar, and buttons in the Fusion style}
156 \caption Fusion
157 \li \image styles/gallery-fusion-dark.webp
158 {Form with text field, combo box, spin box, slider,
159 checkbox, progress bar, and buttons in the Fusion style with a
160 dark palette}
161 \caption Fusion with a dark palette
162 \li \image styles/gallery-macos.webp
163 {Form with text field, combo box, spin box, slider,
164 checkbox, progress bar, and buttons in the macOS style}
165 \caption macOS
166 \endtable
167
168 \section1 Setting a Style
169
170 The style of the entire application can be set using the
171 QApplication::setStyle() function. It can also be specified by the
172 user of the application, using the \c -style command-line option:
173
174 \snippet code/src_gui_styles_qstyle.cpp 0
175
176 If no style is specified, Qt will choose the most appropriate
177 style for the user's platform or desktop environment.
178
179 A style can also be set on an individual widget using the
180 QWidget::setStyle() function.
181
182 \section1 Choosing a Styling Approach
183
184 Choose the mechanism that matches how much you want to change:
185
186 \list
187 \li To adjust the platform style, subclass QProxyStyle.
188 \li To implement a complete custom look, subclass QCommonStyle.
189 \li To describe the design declaratively and share it with Qt Quick
190 Controls, use \l{Qt Labs StyleKit}{StyleKit} and its
191 \l QStyleKitStyle.
192 \endlist
193
194 \l{Styling Approaches for Qt Widgets} compares these options with
195 \l{Qt Style Sheets} and explains when each is appropriate.
196
197 \section1 Developing Style-Aware Custom Widgets
198
199 If you are developing custom widgets and want them to look good on
200 all platforms, you can use QStyle functions to perform parts of
201 the widget drawing, such as drawItemText(), drawItemPixmap(),
202 drawPrimitive(), drawControl(), and drawComplexControl().
203
204 Most QStyle draw functions take four arguments:
205 \list
206 \li an enum value specifying which graphical element to draw
207 \li a QStyleOption specifying how and where to render that element
208 \li a QPainter that should be used to draw the element
209 \li a QWidget on which the drawing is performed (optional)
210 \endlist
211
212 For example, if you want to draw a focus rectangle on your
213 widget, you can write:
214
215 \snippet styles/styles.cpp 1
216
217 QStyle gets all the information it needs to render the graphical
218 element from QStyleOption. The widget is passed as the last
219 argument in case the style needs it to perform special effects
220 (such as animated default buttons on \macos), but it isn't
221 mandatory. In fact, you can use QStyle to draw on any paint
222 device, not just widgets, by setting the QPainter properly.
223
224 QStyleOption has various subclasses for the various types of
225 graphical elements that can be drawn. For example,
226 PE_FrameFocusRect expects a QStyleOptionFocusRect argument.
227
228 To ensure that drawing operations are as fast as possible,
229 QStyleOption and its subclasses have public data members. See the
230 QStyleOption class documentation for details on how to use it.
231
232 For convenience, Qt provides the QStylePainter class, which
233 combines a QStyle, a QPainter, and a QWidget. This makes it
234 possible to write
235
236 \snippet styles/styles.cpp 5
237 \dots
238 \snippet styles/styles.cpp 7
239
240 instead of
241
242 \snippet styles/styles.cpp 2
243 \dots
244 \snippet styles/styles.cpp 3
245
246 \section1 Creating a Custom Style
247
248 You can create a custom look and feel for your application by
249 creating a custom style. There are two approaches. To change
250 selected aspects of an existing style, subclass QProxyStyle and
251 reimplement the virtual functions that draw or measure the elements
252 you want to change; the proxy forwards everything else to the style
253 it wraps, by default the platform style. To implement a complete
254 look, subclass QCommonStyle, which implements the behavior that all
255 of Qt's styles share and leaves the drawing to you. Qt's built-in
256 styles are not part of the public API and cannot serve as base
257 classes; wrap them with QProxyStyle instead.
258
259 Depending on which parts of the base style you want to change,
260 you must reimplement the functions that are used to draw those
261 parts of the interface. To illustrate this, we will modify the
262 look of the spin box arrows drawn by the platform style. The arrows
263 are \e{primitive elements} that are drawn by the drawPrimitive()
264 function, so we need to reimplement that function. We need the
265 following class declaration:
266
267 \snippet customstyle/customstyle.h 0
268
269 To draw its up and down arrows, QSpinBox uses the
270 PE_IndicatorSpinUp and PE_IndicatorSpinDown primitive elements.
271 Here's how to reimplement the drawPrimitive() function to draw
272 them differently:
273
274 \snippet customstyle/customstyle.cpp 2
275
276 Notice that we don't use the \c widget argument, except to pass it
277 on to the QProxyStyle::drawPrimitive() function. As mentioned
278 earlier, the information about what is to be drawn and how it
279 should be drawn is specified by a QStyleOption object, so there is
280 no need to ask the widget.
281
282 If you need to use the \c widget argument to obtain additional
283 information, be careful to ensure that it isn't 0 and that it is
284 of the correct type before using it. For example:
285
286 \snippet customstyle/customstyle.cpp 0
287
288 When implementing a custom style, you cannot assume that the
289 widget is a QSpinBox just because the enum value is called
290 PE_IndicatorSpinUp or PE_IndicatorSpinDown.
291
292 \section1 Using a Custom Style
293
294 There are several ways of using a custom style in a Qt
295 application. The simplest way is to pass the custom style to the
296 QApplication::setStyle() static function before creating the
297 QApplication object:
298
299 \snippet customstyle/main.cpp using a custom style
300
301 You can call QApplication::setStyle() at any time, but by calling
302 it before the constructor, you ensure that the user's preference,
303 set using the \c -style command-line option, is respected.
304
305 You may want to make your custom style available for use in other
306 applications, which may not be yours and hence not available for
307 you to recompile. The Qt Plugin system makes it possible to create
308 styles as plugins. Styles created as plugins are loaded as shared
309 objects at runtime by Qt itself. Please refer to the \l{How to Create Qt Plugins}{Qt Plugin}
310 documentation for more information on how to go about creating a style
311 plugin.
312
313 Compile your plugin and put it into Qt's \c plugins/styles
314 directory. We now have a pluggable style that Qt can load
315 automatically. To use your new style with existing applications,
316 simply start the application with the following argument:
317
318 \snippet code/src_gui_styles_qstyle.cpp 1
319
320 The application will use the look and feel from the custom style you
321 implemented.
322
323 \section1 Right-to-Left Desktops
324
325 Languages written from right to left (such as Arabic and Hebrew)
326 usually also mirror the whole layout of widgets, and require the
327 light to come from the screen's top-right corner instead of
328 top-left.
329
330 If you create a custom style, you should take special care when
331 drawing asymmetric elements to make sure that they also look
332 correct in a mirrored layout. An easy way to test your styles is
333 to run applications with the \c -reverse command-line option or
334 to call QApplication::setLayoutDirection() in your \c main()
335 function.
336
337 Here are some things to keep in mind when making a style work well in a
338 right-to-left environment:
339
340 \list
341 \li subControlRect() and subElementRect() return rectangles in screen coordinates
342 \li QStyleOption::direction indicates in which direction the item should be drawn in
343 \li If a style is not right-to-left aware it will display items as if it were left-to-right
344 \li visualRect(), visualPos(), and visualAlignment() are helpful functions that will
345 translate from logical to screen representations.
346 \li alignedRect() will return a logical rect aligned for the current direction
347 \endlist
348
349 \section1 Styles in Item Views
350
351 The painting of items in views is performed by a delegate. Qt's
352 default delegate, QStyledItemDelegate, is also used for calculating bounding
353 rectangles of items, and their sub-elements for the various kind
354 of item \l{Qt::ItemDataRole}{data roles}
355 QStyledItemDelegate supports. See the QStyledItemDelegate class
356 description to find out which datatypes and roles are supported. You
357 can read more about item data roles in \l{Model/View Programming}.
358
359 When QStyledItemDelegate paints its items, it draws
360 CE_ItemViewItem, and calculates their size with CT_ItemViewItem.
361 Note also that it uses SE_ItemViewItemText to set the size of
362 editors. When implementing a style to customize drawing of item
363 views, you need to check the implementation of QCommonStyle (and
364 any other subclasses from which your style
365 inherits). This way, you find out which and how
366 other style elements are painted, and you can then reimplement the
367 painting of elements that should be drawn differently.
368
369 We include a small example where we customize the drawing of item
370 backgrounds.
371
372 \snippet customviewstyle/customviewstyle.cpp 0
373
374 The primitive element PE_PanelItemViewItem is responsible for
375 painting the background of items, and is called from
376 \l{QCommonStyle}'s implementation of CE_ItemViewItem.
377
378 To add support for drawing of new datatypes and item data roles,
379 it is necessary to create a custom delegate. But if you only
380 need to support the datatypes implemented by the default
381 delegate, a custom style does not need an accompanying
382 delegate. The QStyledItemDelegate class description gives more
383 information on custom delegates.
384
385 The drawing of item view headers is also done by the style, giving
386 control over size of header items and row and column sizes.
387
388 \sa QStyleOption, QStylePainter, {Styles and Style Aware Widgets},
389 {Styling Approaches for Qt Widgets}, QStyledItemDelegate, {Styling}
390*/
391
392/*!
393 Constructs a style object.
394*/
395QStyle::QStyle()
396 : QObject(*new QStylePrivate)
397{
398 Q_D(QStyle);
399 d->proxyStyle = this;
400}
401
402/*!
403 \internal
404
405 Constructs a style object.
406*/
407QStyle::QStyle(QStylePrivate &dd)
408 : QObject(dd)
409{
410 Q_D(QStyle);
411 d->proxyStyle = this;
412 Q_STATIC_ASSERT_X(int(StandardPixmap::NStandardPixmap) ==
413 int(QPlatformTheme::StandardPixmap::NStandardPixmap),
414 "StandardPixmap in QPlatformTheme and QStyle out of sync");
415}
416
417/*!
418 Destroys the style object.
419*/
420QStyle::~QStyle()
421{
422}
423
424/*!
425 Returns the name of the style.
426
427 This value can be used to create a style with QStyleFactory::create().
428
429 \sa QStyleFactory::create()
430 \since 6.1
431*/
432QString QStyle::name() const
433{
434 Q_D(const QStyle);
435 return d->name;
436}
437
438/*!
439 \internal
440 Set the style name
441*/
442void QStyle::setName(const QString &name)
443{
444 Q_D(QStyle);
445 d->name = name;
446}
447
448/*!
449 Initializes the appearance of the given \a widget.
450
451 This function is called for every widget at some point after it
452 has been fully created but just \e before it is shown for the very
453 first time.
454
455 Note that the default implementation does nothing. Reasonable
456 actions in this function might be to call the
457 QWidget::setBackgroundMode() function for the widget. Do not use
458 the function to set, for example, the geometry. Reimplementing
459 this function provides a back-door through which the appearance
460 of a widget can be changed, but with Qt's style engine it is
461 rarely necessary to implement this function; reimplement
462 drawItemPixmap(), drawItemText(), drawPrimitive(), etc. instead.
463
464 The QWidget::inherits() function may provide enough information to
465 allow class-specific customizations. But because new QStyle
466 subclasses are expected to work reasonably with all current and \e
467 future widgets, limited use of hard-coded customization is
468 recommended.
469
470 \sa unpolish()
471*/
472void QStyle::polish(QWidget * /* widget */)
473{
474}
475
476/*!
477 Uninitialize the given \a{widget}'s appearance.
478
479 This function is the counterpart to polish(). It is called for
480 every polished widget whenever the style is dynamically changed;
481 the former style has to unpolish its settings before the new style
482 can polish them again.
483
484 Note that unpolish() will only be called if the widget is
485 destroyed. This can cause problems in some cases, e.g, if you
486 remove a widget from the UI, cache it, and then reinsert it after
487 the style has changed; some of Qt's classes cache their widgets.
488
489 \sa polish()
490*/
491void QStyle::unpolish(QWidget * /* widget */)
492{
493}
494
495/*!
496 \fn void QStyle::polish(QApplication * application)
497 \overload
498
499 Late initialization of the given \a application object.
500*/
501void QStyle::polish(QApplication * /* app */)
502{
503}
504
505/*!
506 \fn void QStyle::unpolish(QApplication * application)
507 \overload
508
509 Uninitialize the given \a application.
510*/
511void QStyle::unpolish(QApplication * /* app */)
512{
513}
514
515/*!
516 \fn void QStyle::polish(QPalette & palette)
517 \overload
518
519 Changes the \a palette according to style specific requirements
520 for color palettes (if any).
521
522 \sa QPalette, QApplication::setPalette()
523*/
524void QStyle::polish(QPalette & /* pal */)
525{
526}
527
528/*!
529 \fn QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const
530
531 Returns the area within the given \a rectangle in which to draw
532 the provided \a text according to the specified font \a metrics
533 and \a alignment. The \a enabled parameter indicates whether or
534 not the associated item is enabled.
535
536 If the given \a rectangle is larger than the area needed to render
537 the \a text, the rectangle that is returned will be offset within
538 \a rectangle according to the specified \a alignment. For
539 example, if \a alignment is Qt::AlignCenter, the returned
540 rectangle will be centered within \a rectangle. If the given \a
541 rectangle is smaller than the area needed, the returned rectangle
542 will be the smallest rectangle large enough to render the \a text.
543
544 \sa Qt::Alignment
545*/
546QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
547 const QString &text) const
548{
549 QRect result;
550 int x, y, w, h;
551 rect.getRect(&x, &y, &w, &h);
552 if (!text.isEmpty()) {
553 result = metrics.boundingRect(x, y, w, h, alignment, text);
554 if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) {
555 result.setWidth(result.width()+1);
556 result.setHeight(result.height()+1);
557 }
558 } else {
559 result = QRect(x, y, w, h);
560 }
561 return result;
562}
563
564/*!
565 \fn QRect QStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
566
567 Returns the area within the given \a rectangle in which to draw
568 the specified \a pixmap according to the defined \a alignment.
569*/
570QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
571{
572 QRect result;
573 int x, y, w, h;
574 rect.getRect(&x, &y, &w, &h);
575
576 QSizeF pixmapSize = pixmap.deviceIndependentSize();
577 const int pixmapWidth = pixmapSize.width();
578 const int pixmapHeight = pixmapSize.height();
579
580 if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
581 y += h/2 - pixmapHeight/2;
582 else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
583 y += h - pixmapHeight;
584 if ((alignment & Qt::AlignRight) == Qt::AlignRight)
585 x += w - pixmapWidth;
586 else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
587 x += w/2 - pixmapWidth/2;
588 else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QGuiApplication::isRightToLeft())
589 x += w - pixmapWidth;
590 result = QRect(x, y, pixmapWidth, pixmapHeight);
591 return result;
592}
593
594/*!
595 \fn void QStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString& text, QPalette::ColorRole textRole) const
596
597 Draws the given \a text in the specified \a rectangle using the
598 provided \a painter and \a palette.
599
600 The text is drawn using the painter's pen, and aligned and wrapped
601 according to the specified \a alignment. If an explicit \a
602 textRole is specified, the text is drawn using the \a palette's
603 color for the given role. The \a enabled parameter indicates
604 whether or not the item is enabled; when reimplementing this
605 function, the \a enabled parameter should influence how the item is
606 drawn.
607
608 \sa Qt::Alignment, drawItemPixmap()
609*/
610void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
611 bool enabled, const QString& text, QPalette::ColorRole textRole) const
612{
613 if (text.isEmpty())
614 return;
615 QPen savedPen;
616 if (textRole != QPalette::NoRole) {
617 savedPen = painter->pen();
618 painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
619 }
620 if (!enabled) {
621 if (proxy()->styleHint(SH_DitherDisabledText)) {
622 QRect br;
623 painter->drawText(rect, alignment, text, &br);
624 painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern));
625 return;
626 } else if (proxy()->styleHint(SH_EtchDisabledText)) {
627 QPen pen = painter->pen();
628 painter->setPen(pal.light().color());
629 painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
630 painter->setPen(pen);
631 }
632 }
633 painter->drawText(rect, alignment, text);
634 if (textRole != QPalette::NoRole)
635 painter->setPen(savedPen);
636}
637
638/*!
639 \fn void QStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment,
640 const QPixmap &pixmap) const
641
642 Draws the given \a pixmap in the specified \a rectangle, according
643 to the specified \a alignment, using the provided \a painter.
644
645 \sa drawItemText()
646*/
647
648void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
649 const QPixmap &pixmap) const
650{
651 qreal scale = pixmap.devicePixelRatio();
652 QRect aligned = alignedRect(QGuiApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect);
653 QRect inter = aligned.intersected(rect);
654
655 // The source rectangle indexes the pixmap's device pixels, so both the
656 // offset and the size of the visible (intersected) area have to be scaled
657 // by the pixmap's device pixel ratio.
658 const QRect source(qRound((inter.x() - aligned.x()) * scale),
659 qRound((inter.y() - aligned.y()) * scale),
660 qRound(inter.width() * scale),
661 qRound(inter.height() * scale));
662
663 painter->drawPixmap(inter.topLeft(), pixmap, source);
664}
665
666/*!
667 \enum QStyle::PrimitiveElement
668
669 This enum describes the various primitive elements. A
670 primitive element is a common GUI element, such as a checkbox
671 indicator or button bevel.
672
673 \value PE_PanelButtonCommand Button used to initiate an action, for
674 example, a QPushButton.
675
676 \value PE_FrameDefaultButton This frame around a default button, e.g. in a dialog.
677 \value PE_PanelButtonBevel Generic panel with a button bevel.
678 \value PE_PanelButtonTool Panel for a Tool button, used with QToolButton.
679 \value PE_PanelLineEdit Panel for a QLineEdit.
680 \value PE_IndicatorButtonDropDown Indicator for a drop down button, for example, a tool
681 button that displays a menu.
682
683 \value PE_FrameFocusRect Generic focus indicator.
684
685 \value PE_IndicatorArrowUp Generic Up arrow.
686 \value PE_IndicatorArrowDown Generic Down arrow.
687 \value PE_IndicatorArrowRight Generic Right arrow.
688 \value PE_IndicatorArrowLeft Generic Left arrow.
689
690 \value PE_IndicatorSpinUp Up symbol for a spin widget, for example a QSpinBox.
691 \value PE_IndicatorSpinDown Down symbol for a spin widget.
692 \value PE_IndicatorSpinPlus Increase symbol for a spin widget.
693 \value PE_IndicatorSpinMinus Decrease symbol for a spin widget.
694
695 \value PE_IndicatorItemViewItemCheck On/off indicator for a view item.
696
697 \value PE_IndicatorCheckBox On/off indicator, for example, a QCheckBox.
698 \value PE_IndicatorRadioButton Exclusive on/off indicator, for example, a QRadioButton.
699
700 \value PE_IndicatorDockWidgetResizeHandle Resize handle for dock windows.
701
702 \value PE_Frame Generic frame
703 \value PE_FrameMenu Frame for popup windows/menus; see also QMenu.
704 \value PE_PanelMenuBar Panel for menu bars.
705 \value PE_PanelScrollAreaCorner Panel at the bottom-right (or
706 bottom-left) corner of a scroll area.
707
708 \value PE_FrameDockWidget Panel frame for dock windows and toolbars.
709 \value PE_FrameTabWidget Frame for tab widgets.
710 \value PE_FrameLineEdit Panel frame for line edits.
711 \value PE_FrameGroupBox Panel frame around group boxes.
712 \value PE_FrameButtonBevel Panel frame for a button bevel.
713 \value PE_FrameButtonTool Panel frame for a tool button.
714
715 \value PE_IndicatorHeaderArrow Arrow used to indicate sorting on a list or table
716 header.
717 \value PE_FrameStatusBarItem Frame for an item of a status bar; see also QStatusBar.
718
719 \value PE_FrameWindow Frame around a MDI window or a docking window.
720
721 \value PE_IndicatorMenuCheckMark Check mark used in a menu.
722
723 \value PE_IndicatorProgressChunk Section of a progress bar indicator; see also QProgressBar.
724
725 \value PE_IndicatorBranch Lines used to represent the branch of a tree in a tree view.
726 \value PE_IndicatorToolBarHandle The handle of a toolbar.
727 \value PE_IndicatorToolBarSeparator The separator in a toolbar.
728 \value PE_PanelToolBar The panel for a toolbar.
729 \value PE_PanelTipLabel The panel for a tip label.
730 \value PE_FrameTabBarBase The frame that is drawn for a tab bar, usually drawn for a tab bar that isn't part of a tab widget.
731 \value PE_IndicatorTabTear Deprecated. Use \l{PE_IndicatorTabTearLeft} instead.
732 \value PE_IndicatorTabTearLeft An indicator that a tab is partially scrolled out on the left side of the visible tab bar when there are many tabs.
733 \value PE_IndicatorTabTearRight An indicator that a tab is partially scrolled out on the right side of the visible tab bar when there are many tabs.
734 \value PE_IndicatorColumnViewArrow An arrow in a QColumnView.
735
736 \value PE_Widget A plain QWidget.
737
738 \value PE_CustomBase Base value for custom primitive elements.
739 All values above this are reserved for custom use. Custom values
740 must be greater than this value.
741
742 \value PE_IndicatorItemViewItemDrop An indicator that is drawn to show where an item in an item view is about to be dropped
743 during a drag-and-drop operation in an item view.
744 \value PE_PanelItemViewItem The background for an item in an item view.
745 \value PE_PanelItemViewRow The background of a row in an item view.
746
747 \value PE_PanelStatusBar The panel for a status bar.
748
749 \value PE_IndicatorTabClose The close button on a tab bar.
750 \value PE_PanelMenu The panel for a menu.
751
752 \sa drawPrimitive()
753*/
754
755
756/*!
757 \enum QStyle::StateFlag
758
759 This enum describes flags that are used when drawing primitive
760 elements.
761
762 Note that not all primitives use all of these flags, and that the
763 flags may mean different things to different items.
764
765 \value State_None Indicates that the widget does not have a state.
766 \value State_Active Indicates that the widget is active.
767 \value State_AutoRaise Used to indicate if auto-raise appearance should be used on a tool button.
768 \value State_Children Used to indicate if an item view branch has children.
769 \value State_DownArrow Used to indicate if a down arrow should be visible on the widget.
770 \value State_Editing Deprecated. No longer used as the editor is drawn over the itemview cell.
771 \value State_Enabled Used to indicate if the widget is enabled.
772 \value State_HasFocus Used to indicate if the widget has focus.
773 \value State_Horizontal Used to indicate if the widget is laid out horizontally, for example. a tool bar.
774 \value State_KeyboardFocusChange Used to indicate if the focus was changed with the keyboard, e.g., tab, backtab or shortcut.
775 \value State_MouseOver Used to indicate if the widget is under the mouse.
776 \value State_NoChange Used to indicate a tri-state checkbox.
777 \value State_Off Used to indicate if the widget is not checked.
778 \value State_On Used to indicate if the widget is checked.
779 \value State_Raised Used to indicate if a button is raised.
780 \value State_ReadOnly Used to indicate if a widget is read-only.
781 \value State_Selected Used to indicate if a widget is selected.
782 \value State_Item Used by item views to indicate if a horizontal branch should be drawn.
783 \value State_Open Used by item views to indicate if the tree branch is open.
784 \value State_Sibling Used by item views to indicate if a vertical line needs to be drawn (for siblings).
785 \value State_Sunken Used to indicate if the widget is sunken or pressed.
786 \value State_UpArrow Used to indicate if an up arrow should be visible on the widget.
787 \value State_Mini Used to indicate a mini style Mac widget or button.
788 \value State_Small Used to indicate a small style Mac widget or button.
789 \omitvalue State_Window
790 \omitvalue State_Bottom
791 \omitvalue State_FocusAtBorder
792 \omitvalue State_Top
793
794 \sa drawPrimitive()
795*/
796
797/*!
798 \fn void QStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
799
800 Draws the given primitive \a element with the provided \a painter using the style
801 options specified by \a option.
802
803 The \a widget argument is optional and may contain a widget that may
804 aid in drawing the primitive element.
805
806 The table below is listing the primitive elements and their
807 associated style option subclasses. The style options contain all
808 the parameters required to draw the elements, including
809 QStyleOption::state which holds the style flags that are used when
810 drawing. The table also describes which flags that are set when
811 casting the given option to the appropriate subclass.
812
813 Note that if a primitive element is not listed here, it is because
814 it uses a plain QStyleOption object.
815
816 \table
817 \header \li Primitive Element \li QStyleOption Subclass \li Style Flag \li Remark
818 \row \li \l PE_FrameFocusRect \li \l QStyleOptionFocusRect
819 \li \l State_FocusAtBorder
820 \li Whether the focus is is at the border or inside the widget.
821 \row \li{1,2} \l PE_IndicatorCheckBox \li{1,2} \l QStyleOptionButton
822 \li \l State_NoChange \li Indicates a "tri-state" checkbox.
823 \row \li \l State_On \li Indicates the indicator is checked.
824 \row \li \l PE_IndicatorRadioButton \li \l QStyleOptionButton
825 \li \l State_On \li Indicates that a radio button is selected.
826 \row \li \l State_NoChange \li Indicates a "tri-state" controller.
827 \row \li \l State_Enabled \li Indicates the controller is enabled.
828 \row \li{1,4} \l PE_IndicatorBranch \li{1,4} \l QStyleOption
829 \li \l State_Children \li Indicates that the control for expanding the tree to show child items, should be drawn.
830 \row \li \l State_Item \li Indicates that a horizontal branch (to show a child item), should be drawn.
831 \row \li \l State_Open \li Indicates that the tree branch is expanded.
832 \row \li \l State_Sibling \li Indicates that a vertical line (to show a sibling item), should be drawn.
833 \row \li \l PE_IndicatorHeaderArrow \li \l QStyleOptionHeader
834 \li \l State_UpArrow \li Indicates that the arrow should be drawn up;
835 otherwise it should be down.
836 \row \li \l PE_FrameGroupBox, \l PE_Frame, \l PE_FrameLineEdit,
837 \l PE_FrameMenu, \l PE_FrameDockWidget, \l PE_FrameWindow
838 \li \l QStyleOptionFrame \li \l State_Sunken
839 \li Indicates that the Frame should be sunken.
840 \row \li \l PE_IndicatorToolBarHandle \li \l QStyleOption
841 \li \l State_Horizontal \li Indicates that the window handle is horizontal
842 instead of vertical.
843 \row \li \l PE_IndicatorSpinPlus, \l PE_IndicatorSpinMinus, \l PE_IndicatorSpinUp,
844 \l PE_IndicatorSpinDown,
845 \li \l QStyleOptionSpinBox
846 \li \l State_Sunken \li Indicates that the button is pressed.
847 \row \li{1,5} \l PE_PanelButtonCommand
848 \li{1,5} \l QStyleOptionButton
849 \li \l State_Enabled \li Set if the button is enabled.
850 \row \li \l State_HasFocus \li Set if the button has input focus.
851 \row \li \l State_Raised \li Set if the button is not down, not on and not flat.
852 \row \li \l State_On \li Set if the button is a toggle button and is toggled on.
853 \row \li \l State_Sunken
854 \li Set if the button is down (i.e., the mouse button or the
855 space bar is pressed on the button).
856 \endtable
857
858 \sa drawComplexControl(), drawControl()
859*/
860
861/*!
862 \enum QStyle::ControlElement
863
864 This enum represents a control element. A control element is a
865 part of a widget that performs some action or displays information
866 to the user.
867
868 \value CE_PushButton A QPushButton, draws CE_PushButtonBevel, CE_PushButtonLabel and PE_FrameFocusRect.
869 \value CE_PushButtonBevel The bevel and default indicator of a QPushButton.
870 \value CE_PushButtonLabel The label (an icon with text or pixmap) of a QPushButton.
871
872 \value CE_DockWidgetTitle Dock window title.
873 \value CE_Splitter Splitter handle; see also QSplitter.
874
875
876 \value CE_CheckBox A QCheckBox, draws a PE_IndicatorCheckBox, a CE_CheckBoxLabel and a PE_FrameFocusRect.
877 \value CE_CheckBoxLabel The label (text or pixmap) of a QCheckBox.
878
879 \value CE_RadioButton A QRadioButton, draws a PE_IndicatorRadioButton, a CE_RadioButtonLabel and a PE_FrameFocusRect.
880 \value CE_RadioButtonLabel The label (text or pixmap) of a QRadioButton.
881
882 \value CE_TabBarTab The tab and label within a QTabBar.
883 \value CE_TabBarTabShape The tab shape within a tab bar.
884 \value CE_TabBarTabLabel The label within a tab.
885
886 \value CE_ProgressBar A QProgressBar, draws CE_ProgressBarGroove, CE_ProgressBarContents and CE_ProgressBarLabel.
887 \value CE_ProgressBarGroove The groove where the progress
888 indicator is drawn in a QProgressBar.
889 \value CE_ProgressBarContents The progress indicator of a QProgressBar.
890 \value CE_ProgressBarLabel The text label of a QProgressBar.
891
892 \value CE_ToolButtonLabel A tool button's label.
893
894 \value CE_MenuBarItem A menu item in a QMenuBar.
895 \value CE_MenuBarEmptyArea The empty area of a QMenuBar.
896
897 \value CE_MenuItem A menu item in a QMenu.
898 \value CE_MenuScroller Scrolling areas in a QMenu when the
899 style supports scrolling.
900 \value CE_MenuTearoff A menu item representing the tear off section of
901 a QMenu.
902 \value CE_MenuEmptyArea The area in a menu without menu items.
903 \value CE_MenuHMargin The horizontal extra space on the left/right of a menu.
904 \value CE_MenuVMargin The vertical extra space on the top/bottom of a menu.
905
906 \value CE_ToolBoxTab The toolbox's tab and label within a QToolBox.
907 \value CE_SizeGrip Window resize handle; see also QSizeGrip.
908
909 \value CE_Header A header.
910 \value CE_HeaderSection A header section.
911 \value CE_HeaderLabel The header's label.
912
913 \value CE_ScrollBarAddLine Scroll bar line increase indicator.
914 (i.e., scroll down); see also QScrollBar.
915 \value CE_ScrollBarSubLine Scroll bar line decrease indicator (i.e., scroll up).
916 \value CE_ScrollBarAddPage Scolllbar page increase indicator (i.e., page down).
917 \value CE_ScrollBarSubPage Scroll bar page decrease indicator (i.e., page up).
918 \value CE_ScrollBarSlider Scroll bar slider.
919 \value CE_ScrollBarFirst Scroll bar first line indicator (i.e., home).
920 \value CE_ScrollBarLast Scroll bar last line indicator (i.e., end).
921
922 \value CE_RubberBand Rubber band used in for example an icon view.
923
924 \value CE_FocusFrame Focus frame that is style controlled.
925
926 \value CE_ItemViewItem An item inside an item view.
927
928 \value CE_CustomBase Base value for custom control elements;
929 custom values must be greater than this value.
930 \value CE_ComboBoxLabel The label of a non-editable QComboBox.
931 \value CE_ToolBar A toolbar like QToolBar.
932 \value CE_ToolBoxTabShape The toolbox's tab shape.
933 \value CE_ToolBoxTabLabel The toolbox's tab label.
934 \value CE_HeaderEmptyArea The area of a header view where there are no header sections.
935
936 \value CE_ShapedFrame The frame with the shape specified in the QStyleOptionFrame; see QFrame.
937
938 \omitvalue CE_ColumnViewGrip
939
940 \sa drawControl()
941*/
942
943/*!
944 \fn void QStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
945
946 Draws the given \a element with the provided \a painter with the
947 style options specified by \a option.
948
949 The \a widget argument is optional and can be used as aid in
950 drawing the control. The \a option parameter is a pointer to a
951 QStyleOption object that can be cast to the correct subclass
952 using the qstyleoption_cast() function.
953
954 The table below is listing the control elements and their
955 associated style option subclass. The style options contain all
956 the parameters required to draw the controls, including
957 QStyleOption::state which holds the style flags that are used when
958 drawing. The table also describes which flags that are set when
959 casting the given option to the appropriate subclass.
960
961 Note that if a control element is not listed here, it is because
962 it uses a plain QStyleOption object.
963
964 \table
965 \header \li Control Element \li QStyleOption Subclass \li Style Flag \li Remark
966 \row \li{1,5} \l CE_MenuItem, \l CE_MenuBarItem
967 \li{1,5} \l QStyleOptionMenuItem
968 \li \l State_Selected \li The menu item is currently selected item.
969 \row \li \l State_Enabled \li The item is enabled.
970 \row \li \l State_DownArrow \li Indicates that a scroll down arrow should be drawn.
971 \row \li \l State_UpArrow \li Indicates that a scroll up arrow should be drawn
972 \row \li \l State_HasFocus \li Set if the menu bar has input focus.
973
974 \row \li{1,5} \l CE_PushButton, \l CE_PushButtonBevel, \l CE_PushButtonLabel
975 \li{1,5} \l QStyleOptionButton
976 \li \l State_Enabled \li Set if the button is enabled.
977 \row \li \l State_HasFocus \li Set if the button has input focus.
978 \row \li \l State_Raised \li Set if the button is not down, not on and not flat.
979 \row \li \l State_On \li Set if the button is a toggle button and is toggled on.
980 \row \li \l State_Sunken
981 \li Set if the button is down (i.e., the mouse button or the
982 space bar is pressed on the button).
983
984 \row \li{1,6} \l CE_RadioButton, \l CE_RadioButtonLabel,
985 \l CE_CheckBox, \l CE_CheckBoxLabel
986 \li{1,6} \l QStyleOptionButton
987 \li \l State_Enabled \li Set if the button is enabled.
988 \row \li \l State_HasFocus \li Set if the button has input focus.
989 \row \li \l State_On \li Set if the button is checked.
990 \row \li \l State_Off \li Set if the button is not checked.
991 \row \li \l State_NoChange \li Set if the button is in the NoChange state.
992 \row \li \l State_Sunken
993 \li Set if the button is down (i.e., the mouse button or
994 the space bar is pressed on the button).
995
996 \row \li{1,2} \l CE_ProgressBarContents, \l CE_ProgressBarLabel,
997 \l CE_ProgressBarGroove
998 \li{1,2} \l QStyleOptionProgressBar
999 \li \l State_Enabled \li Set if the progress bar is enabled.
1000 \row \li \l State_HasFocus \li Set if the progress bar has input focus.
1001
1002 \row \li \l CE_Header, \l CE_HeaderSection, \l CE_HeaderLabel \li \l QStyleOptionHeader \li \li
1003
1004 \row \li{1,3} \l CE_TabBarTab, CE_TabBarTabShape, CE_TabBarTabLabel
1005 \li{1,3} \l QStyleOptionTab
1006 \li \l State_Enabled \li Set if the tab bar is enabled.
1007 \row \li \l State_Selected \li The tab bar is the currently selected tab bar.
1008 \row \li \l State_HasFocus \li Set if the tab bar tab has input focus.
1009
1010 \row \li{1,7} \l CE_ToolButtonLabel
1011 \li{1,7} \l QStyleOptionToolButton
1012 \li \l State_Enabled \li Set if the tool button is enabled.
1013 \row \li \l State_HasFocus \li Set if the tool button has input focus.
1014 \row \li \l State_Sunken
1015 \li Set if the tool button is down (i.e., a mouse button or
1016 the space bar is pressed).
1017 \row \li \l State_On \li Set if the tool button is a toggle button and is toggled on.
1018 \row \li \l State_AutoRaise \li Set if the tool button has auto-raise enabled.
1019 \row \li \l State_MouseOver \li Set if the mouse pointer is over the tool button.
1020 \row \li \l State_Raised \li Set if the button is not down and is not on.
1021
1022 \row \li \l CE_ToolBoxTab \li \l QStyleOptionToolBox
1023 \li \l State_Selected \li The tab is the currently selected tab.
1024 \row \li \l CE_RubberBand \li \l QStyleOptionRubberBand \li \li
1025 \row \li \l CE_ProgressBar \li \l QStyleOptionProgressBar \li \li
1026 \row \li \l CE_ToolBoxTabShape, \l CE_ToolBoxTabLabel \li \l QStyleOptionToolBox \li \li
1027 \row \li \l CE_ComboBoxLabel \li \l QStyleOptionComboBox \li \li
1028 \row \li \l CE_DockWidgetTitle \li \l QStyleOptionDockWidget \li \li
1029 \row \li \l CE_ShapedFrame \li \l QStyleOptionFrame \li \li
1030 \row \li \l CE_ToolBar \li \l QStyleOptionToolBar \li \li
1031 \row \li \l CE_ItemViewItem \li \l QStyleOptionViewItem \li \li
1032 \row \li \l CE_SizeGrip \li \l QStyleOptionSizeGrip \li
1033 \li Optional. Without it, the corner is chosen from the layout direction.
1034 \row \li{1,3} \l CE_HeaderSection \li{1,3} \l QStyleOptionHeader
1035 \li \l State_Sunken \li Indicates that the section is pressed.
1036 \row \li \l State_UpArrow \li Indicates that the sort indicator should be pointing up.
1037 \row \li \l State_DownArrow \li Indicates that the sort indicator should be pointing down.
1038 \endtable
1039
1040 \sa drawPrimitive(), drawComplexControl()
1041*/
1042
1043/*!
1044 \enum QStyle::SubElement
1045
1046 This enum represents a sub-area of a widget. Style implementations
1047 use these areas to draw the different parts of a widget.
1048
1049 \value SE_PushButtonContents Area containing the label (icon
1050 with text or pixmap).
1051 \value SE_PushButtonFocusRect Area for the focus rect (usually
1052 larger than the contents rect).
1053 \value SE_PushButtonLayoutItem Area that counts for the parent layout.
1054 \value [since 5.15] SE_PushButtonBevel Area used for the bevel of the button.
1055
1056 \value SE_CheckBoxIndicator Area for the state indicator (e.g., check mark).
1057 \value SE_CheckBoxContents Area for the label (text or pixmap).
1058 \value SE_CheckBoxFocusRect Area for the focus indicator.
1059 \value SE_CheckBoxClickRect Clickable area, defaults to SE_CheckBoxFocusRect.
1060 \value SE_CheckBoxLayoutItem Area that counts for the parent layout.
1061
1062 \value SE_DateTimeEditLayoutItem Area that counts for the parent layout.
1063
1064 \value SE_RadioButtonIndicator Area for the state indicator.
1065 \value SE_RadioButtonContents Area for the label.
1066 \value SE_RadioButtonFocusRect Area for the focus indicator.
1067 \value SE_RadioButtonClickRect Clickable area, defaults to SE_RadioButtonFocusRect.
1068 \value SE_RadioButtonLayoutItem Area that counts for the parent layout.
1069
1070 \value SE_ComboBoxFocusRect Area for the focus indicator.
1071
1072 \value SE_SliderFocusRect Area for the focus indicator.
1073 \value SE_SliderLayoutItem Area that counts for the parent layout.
1074
1075 \value SE_SpinBoxLayoutItem Area that counts for the parent layout.
1076
1077 \value SE_ProgressBarGroove Area for the groove.
1078 \value SE_ProgressBarContents Area for the progress indicator.
1079 \value SE_ProgressBarLabel Area for the text label.
1080 \value SE_ProgressBarLayoutItem Area that counts for the parent layout.
1081
1082 \value SE_FrameContents Area for a frame's contents.
1083 \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrame; see QFrame
1084 \value SE_FrameLayoutItem Area that counts for the parent layout.
1085
1086 \value SE_HeaderArrow Area for the sort indicator for a header.
1087 \value SE_HeaderLabel Area for the label in a header.
1088
1089 \value SE_LabelLayoutItem Area that counts for the parent layout.
1090
1091 \value SE_LineEditContents Area for a line edit's contents.
1092
1093 \value SE_TabWidgetLeftCorner Area for the left corner widget in a tab widget.
1094 \value SE_TabWidgetRightCorner Area for the right corner widget in a tab widget.
1095 \value SE_TabWidgetTabBar Area for the tab bar widget in a tab widget.
1096 \value SE_TabWidgetTabContents Area for the contents of the tab widget.
1097 \value SE_TabWidgetTabPane Area for the pane of a tab widget.
1098 \value SE_TabWidgetLayoutItem Area that counts for the parent layout.
1099
1100 \value SE_ToolBoxTabContents Area for a toolbox tab's icon and label.
1101
1102 \value SE_ToolButtonLayoutItem Area that counts for the parent layout.
1103
1104 \value SE_ItemViewItemCheckIndicator Area for a view item's check mark.
1105
1106 \value SE_TabBarTearIndicator Deprecated. Use SE_TabBarTearIndicatorLeft instead.
1107 \value SE_TabBarTearIndicatorLeft Area for the tear indicator on the left side of a tab bar with scroll arrows.
1108 \value SE_TabBarTearIndicatorRight Area for the tear indicator on the right side of a tab bar with scroll arrows.
1109
1110 \value SE_TabBarScrollLeftButton Area for the scroll left button on a tab bar with scroll buttons.
1111 \value SE_TabBarScrollRightButton Area for the scroll right button on a tab bar with scroll buttons.
1112
1113 \value SE_TreeViewDisclosureItem Area for the actual disclosure item in a tree branch.
1114
1115 \value SE_GroupBoxLayoutItem Area that counts for the parent layout.
1116
1117 \value SE_CustomBase Base value for custom sub-elements.
1118 Custom values must be greater than this value.
1119
1120 \value SE_DockWidgetFloatButton The float button of a dock
1121 widget.
1122 \value SE_DockWidgetTitleBarText The text bounds of the dock
1123 widgets title.
1124 \value SE_DockWidgetCloseButton The close button of a dock
1125 widget.
1126 \value SE_DockWidgetIcon The icon of a dock widget.
1127 \value SE_ComboBoxLayoutItem Area that counts for the parent layout.
1128
1129
1130 \value SE_ItemViewItemDecoration Area for a view item's decoration (icon).
1131 \value SE_ItemViewItemText Area for a view item's text.
1132 \value SE_ItemViewItemFocusRect Area for a view item's focus rect.
1133
1134 \value SE_TabBarTabLeftButton Area for a widget on the left side of a tab in a tab bar.
1135 \value SE_TabBarTabRightButton Area for a widget on the right side of a tab in a tab bar.
1136 \value SE_TabBarTabText Area for the text on a tab in a tab bar.
1137
1138 \value SE_ToolBarHandle Area for the handle of a tool bar.
1139
1140 \sa subElementRect()
1141*/
1142
1143/*!
1144 \fn QRect QStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
1145
1146 Returns the sub-area for the given \a element as described in the
1147 provided style \a option. The returned rectangle is defined in
1148 screen coordinates.
1149
1150 The \a widget argument is optional and can be used to aid
1151 determining the area. The QStyleOption object can be cast to the
1152 appropriate type using the qstyleoption_cast() function. See the
1153 table below for the appropriate \a option casts:
1154
1155 \table
1156 \header \li Sub Element \li QStyleOption Subclass
1157 \row \li \l SE_PushButtonContents \li \l QStyleOptionButton
1158 \row \li \l SE_PushButtonFocusRect \li \l QStyleOptionButton
1159 \row \li \l SE_PushButtonBevel \li \l QStyleOptionButton
1160 \row \li \l SE_CheckBoxIndicator \li \l QStyleOptionButton
1161 \row \li \l SE_CheckBoxContents \li \l QStyleOptionButton
1162 \row \li \l SE_CheckBoxFocusRect \li \l QStyleOptionButton
1163 \row \li \l SE_RadioButtonIndicator \li \l QStyleOptionButton
1164 \row \li \l SE_RadioButtonContents \li \l QStyleOptionButton
1165 \row \li \l SE_RadioButtonFocusRect \li \l QStyleOptionButton
1166 \row \li \l SE_ComboBoxFocusRect \li \l QStyleOptionComboBox
1167 \row \li \l SE_ProgressBarGroove \li \l QStyleOptionProgressBar
1168 \row \li \l SE_ProgressBarContents \li \l QStyleOptionProgressBar
1169 \row \li \l SE_ProgressBarLabel \li \l QStyleOptionProgressBar
1170 \endtable
1171*/
1172
1173/*!
1174 \enum QStyle::ComplexControl
1175
1176 This enum describes the available complex controls. Complex
1177 controls have different behavior depending upon where the user
1178 clicks on them or which keys are pressed.
1179
1180 \value CC_SpinBox A spinbox, like QSpinBox.
1181 \value CC_ComboBox A combobox, like QComboBox.
1182 \value CC_ScrollBar A scroll bar, like QScrollBar.
1183 \value CC_Slider A slider, like QSlider.
1184 \value CC_ToolButton A tool button, like QToolButton.
1185 \value CC_TitleBar A Title bar, like those used in QMdiSubWindow.
1186 \value CC_GroupBox A group box, like QGroupBox.
1187 \value CC_Dial A dial, like QDial.
1188 \value CC_MdiControls The minimize, close, and normal
1189 button in the menu bar for a
1190 maximized MDI subwindow.
1191
1192 \value CC_CustomBase Base value for custom complex controls. Custom
1193 values must be greater than this value.
1194
1195 \sa SubControl, drawComplexControl()
1196*/
1197
1198/*!
1199 \enum QStyle::SubControl
1200
1201 This enum describes the available sub controls. A subcontrol is a
1202 control element within a complex control (ComplexControl).
1203
1204 \value SC_None Special value that matches no other sub control.
1205
1206 \value SC_ScrollBarAddLine Scroll bar add line (i.e., down/right
1207 arrow); see also QScrollBar.
1208 \value SC_ScrollBarSubLine Scroll bar sub line (i.e., up/left arrow).
1209 \value SC_ScrollBarAddPage Scroll bar add page (i.e., page down).
1210 \value SC_ScrollBarSubPage Scroll bar sub page (i.e., page up).
1211 \value SC_ScrollBarFirst Scroll bar first line (i.e., home).
1212 \value SC_ScrollBarLast Scroll bar last line (i.e., end).
1213 \value SC_ScrollBarSlider Scroll bar slider handle.
1214 \value SC_ScrollBarGroove Special sub-control which contains the
1215 area in which the slider handle may move.
1216
1217 \value SC_SpinBoxUp Spin widget up/increase; see also QSpinBox.
1218 \value SC_SpinBoxDown Spin widget down/decrease.
1219 \value SC_SpinBoxFrame Spin widget frame.
1220 \value SC_SpinBoxEditField Spin widget edit field.
1221
1222 \value SC_ComboBoxEditField Combobox edit field; see also QComboBox.
1223 \value SC_ComboBoxArrow Combobox arrow button.
1224 \value SC_ComboBoxFrame Combobox frame.
1225 \value SC_ComboBoxListBoxPopup The reference rectangle for the combobox popup.
1226 Used to calculate the position of the popup.
1227
1228 \value SC_SliderGroove Special sub-control which contains the area
1229 in which the slider handle may move.
1230 \value SC_SliderHandle Slider handle.
1231 \value SC_SliderTickmarks Slider tickmarks.
1232
1233 \value SC_ToolButton Tool button (see also QToolButton).
1234 \value SC_ToolButtonMenu Sub-control for opening a popup menu in a
1235 tool button.
1236
1237 \value SC_TitleBarSysMenu System menu button (i.e., restore, close, etc.).
1238 \value SC_TitleBarMinButton Minimize button.
1239 \value SC_TitleBarMaxButton Maximize button.
1240 \value SC_TitleBarCloseButton Close button.
1241 \value SC_TitleBarLabel Window title label.
1242 \value SC_TitleBarNormalButton Normal (restore) button.
1243 \value SC_TitleBarShadeButton Shade button.
1244 \value SC_TitleBarUnshadeButton Unshade button.
1245 \value SC_TitleBarContextHelpButton Context Help button.
1246
1247 \value SC_DialHandle The handle of the dial (i.e. what you use to control the dial).
1248 \value SC_DialGroove The groove for the dial.
1249 \value SC_DialTickmarks The tickmarks for the dial.
1250
1251 \value SC_GroupBoxFrame The frame of a group box.
1252 \value SC_GroupBoxLabel The title of a group box.
1253 \value SC_GroupBoxCheckBox The optional checkbox of a group box.
1254 \value SC_GroupBoxContents The group box contents.
1255
1256 \value SC_MdiNormalButton The normal button for a MDI
1257 subwindow in the menu bar.
1258 \value SC_MdiMinButton The minimize button for a MDI
1259 subwindow in the menu bar.
1260 \value SC_MdiCloseButton The close button for a MDI subwindow
1261 in the menu bar.
1262
1263 \value SC_All Special value that matches all sub-controls.
1264 \omitvalue SC_CustomBase
1265
1266 \sa ComplexControl
1267*/
1268
1269/*!
1270 \fn void QStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
1271
1272 Draws the given \a control using the provided \a painter with the
1273 style options specified by \a option.
1274
1275 The \a widget argument is optional and can be used as aid in
1276 drawing the control.
1277
1278 The \a option parameter is a pointer to a QStyleOptionComplex
1279 object that can be cast to the correct subclass using the
1280 qstyleoption_cast() function. Note that the \c rect member of the
1281 specified \a option must be in logical
1282 coordinates. Reimplementations of this function should use
1283 visualRect() to change the logical coordinates into screen
1284 coordinates before calling the drawPrimitive() or drawControl()
1285 function.
1286
1287 The table below is listing the complex control elements and their
1288 associated style option subclass. The style options contain all
1289 the parameters required to draw the controls, including
1290 QStyleOption::state which holds the \l {QStyle::StateFlag}{style
1291 flags} that are used when drawing. The table also describes which
1292 flags that are set when casting the given \a option to the
1293 appropriate subclass.
1294
1295 \table
1296 \header \li Complex Control \li QStyleOptionComplex Subclass \li Style Flag \li Remark
1297 \row \li{1,2} \l{CC_SpinBox} \li{1,2} \l QStyleOptionSpinBox
1298 \li \l State_Enabled \li Set if the spin box is enabled.
1299 \row \li \l State_HasFocus \li Set if the spin box has input focus.
1300
1301 \row \li{1,2} \l {CC_ComboBox} \li{1,2} \l QStyleOptionComboBox
1302 \li \l State_Enabled \li Set if the combobox is enabled.
1303 \row \li \l State_HasFocus \li Set if the combobox has input focus.
1304
1305 \row \li{1,2} \l {CC_ScrollBar} \li{1,2} \l QStyleOptionSlider
1306 \li \l State_Enabled \li Set if the scroll bar is enabled.
1307 \row \li \l State_HasFocus \li Set if the scroll bar has input focus.
1308
1309 \row \li{1,2} \l {CC_Slider} \li{1,2} \l QStyleOptionSlider
1310 \li \l State_Enabled \li Set if the slider is enabled.
1311 \row \li \l State_HasFocus \li Set if the slider has input focus.
1312
1313 \row \li{1,2} \l {CC_Dial} \li{1,2} \l QStyleOptionSlider
1314 \li \l State_Enabled \li Set if the dial is enabled.
1315 \row \li \l State_HasFocus \li Set if the dial has input focus.
1316
1317 \row \li{1,6} \l {CC_ToolButton} \li{1,6} \l QStyleOptionToolButton
1318 \li \l State_Enabled \li Set if the tool button is enabled.
1319 \row \li \l State_HasFocus \li Set if the tool button has input focus.
1320 \row \li \l State_DownArrow \li Set if the tool button is down (i.e., a mouse
1321 button or the space bar is pressed).
1322 \row \li \l State_On \li Set if the tool button is a toggle button
1323 and is toggled on.
1324 \row \li \l State_AutoRaise \li Set if the tool button has auto-raise enabled.
1325 \row \li \l State_Raised \li Set if the button is not down, not on, and doesn't
1326 contain the mouse when auto-raise is enabled.
1327
1328 \row \li \l{CC_TitleBar} \li \l QStyleOptionTitleBar
1329 \li \l State_Enabled \li Set if the title bar is enabled.
1330
1331 \endtable
1332
1333 \sa drawPrimitive(), drawControl()
1334*/
1335
1336
1337/*!
1338 \fn QRect QStyle::subControlRect(ComplexControl control,
1339 const QStyleOptionComplex *option, SubControl subControl,
1340 const QWidget *widget) const = 0
1341
1342 Returns the rectangle containing the specified \a subControl of
1343 the given complex \a control (with the style specified by \a
1344 option). The rectangle is defined in screen coordinates.
1345
1346 The \a option argument is a pointer to QStyleOptionComplex or
1347 one of its subclasses, and can be cast to the appropriate type
1348 using the qstyleoption_cast() function. See drawComplexControl()
1349 for details. The \a widget is optional and can contain additional
1350 information for the function.
1351
1352 \sa drawComplexControl()
1353*/
1354
1355/*!
1356 \fn QStyle::SubControl QStyle::hitTestComplexControl(ComplexControl control,
1357 const QStyleOptionComplex *option, const QPoint &position,
1358 const QWidget *widget) const = 0
1359
1360 Returns the sub control at the given \a position in the given
1361 complex \a control (with the style options specified by \a
1362 option).
1363
1364 Note that the \a position is expressed in screen coordinates.
1365
1366 The \a option argument is a pointer to a QStyleOptionComplex
1367 object (or one of its subclasses). The object can be cast to the
1368 appropriate type using the qstyleoption_cast() function. See
1369 drawComplexControl() for details. The \a widget argument is
1370 optional and can contain additional information for the function.
1371
1372 \sa drawComplexControl(), subControlRect()
1373*/
1374
1375/*!
1376 \enum QStyle::PixelMetric
1377
1378 This enum describes the various available pixel metrics. A pixel
1379 metric is a style dependent size represented by a single pixel
1380 value.
1381
1382 \value PM_ButtonMargin Amount of whitespace between push button
1383 labels and the frame.
1384 \value PM_DockWidgetTitleBarButtonMargin Amount of whitespace between dock widget's
1385 title bar button labels and the frame.
1386 \value PM_ButtonDefaultIndicator Width of the default-button indicator frame.
1387 \value PM_MenuButtonIndicator Width of the menu button indicator
1388 proportional to the widget height.
1389 \value PM_ButtonShiftHorizontal Horizontal contents shift of a
1390 button when the button is down.
1391 \value PM_ButtonShiftVertical Vertical contents shift of a button when the
1392 button is down.
1393
1394 \value PM_DefaultFrameWidth Default frame width (usually 2).
1395 \value PM_SpinBoxFrameWidth Frame width of a spin box, defaults to PM_DefaultFrameWidth.
1396 \value PM_ComboBoxFrameWidth Frame width of a combo box, defaults to PM_DefaultFrameWidth.
1397
1398 \value PM_MdiSubWindowFrameWidth Frame width of an MDI window.
1399 \value PM_MdiSubWindowMinimizedWidth Width of a minimized MDI window.
1400
1401 \value PM_LayoutLeftMargin Default \l{QLayout::setContentsMargins()}{left margin} for a
1402 QLayout.
1403 \value PM_LayoutTopMargin Default \l{QLayout::setContentsMargins()}{top margin} for a QLayout.
1404 \value PM_LayoutRightMargin Default \l{QLayout::setContentsMargins()}{right margin} for a
1405 QLayout.
1406 \value PM_LayoutBottomMargin Default \l{QLayout::setContentsMargins()}{bottom margin} for a
1407 QLayout.
1408 \value PM_LayoutHorizontalSpacing Default \l{QLayout::spacing}{horizontal spacing} for a
1409 QLayout.
1410 \value PM_LayoutVerticalSpacing Default \l{QLayout::spacing}{vertical spacing} for a QLayout.
1411
1412 \value PM_MaximumDragDistance The maximum allowed distance between
1413 the mouse and a scrollbar when dragging. Exceeding the specified
1414 distance will cause the slider to jump back to the original
1415 position; a value of -1 disables this behavior.
1416
1417 \value PM_ScrollBarExtent Width of a vertical scroll bar and the
1418 height of a horizontal scroll bar.
1419 \value PM_ScrollBarSliderMin The minimum height of a vertical
1420 scroll bar's slider and the minimum width of a horizontal
1421 scroll bar's slider.
1422
1423 \value PM_SliderThickness Total slider thickness.
1424 \value PM_SliderControlThickness Thickness of the slider handle.
1425 \value PM_SliderLength Length of the slider.
1426 \value PM_SliderTickmarkOffset The offset between the tickmarks
1427 and the slider.
1428 \value PM_SliderSpaceAvailable The available space for the slider to move.
1429
1430 \value PM_DockWidgetSeparatorExtent Width of a separator in a
1431 horizontal dock window and the height of a separator in a
1432 vertical dock window.
1433 \value PM_DockWidgetHandleExtent Width of the handle in a
1434 horizontal dock window and the height of the handle in a
1435 vertical dock window.
1436 \value PM_DockWidgetFrameWidth Frame width of a dock window.
1437 \value PM_DockWidgetTitleMargin Margin of the dock window title.
1438
1439 \value PM_MenuBarPanelWidth Frame width of a menu bar, defaults to PM_DefaultFrameWidth.
1440 \value PM_MenuBarItemSpacing Spacing between menu bar items.
1441 \value PM_MenuBarHMargin Spacing between menu bar items and left/right of bar.
1442 \value PM_MenuBarVMargin Spacing between menu bar items and top/bottom of bar.
1443
1444 \value PM_ToolBarFrameWidth Width of the frame around toolbars.
1445 \value PM_ToolBarHandleExtent Width of a toolbar handle in a
1446 horizontal toolbar and the height of the handle in a vertical toolbar.
1447 \value PM_ToolBarItemMargin Spacing between the toolbar frame and the items.
1448 \value PM_ToolBarItemSpacing Spacing between toolbar items.
1449 \value PM_ToolBarSeparatorExtent Width of a toolbar separator in a
1450 horizontal toolbar and the height of a separator in a vertical toolbar.
1451 \value PM_ToolBarExtensionExtent Width of a toolbar extension
1452 button in a horizontal toolbar and the height of the button in a
1453 vertical toolbar.
1454
1455 \value PM_TabBarTabOverlap Number of pixels the tabs should overlap.
1456 (Currently only used in styles, not inside of QTabBar)
1457 \value PM_TabBarTabHSpace Extra space added to the tab width.
1458 \value PM_TabBarTabVSpace Extra space added to the tab height.
1459 \value PM_TabBarBaseHeight Height of the area between the tab bar
1460 and the tab pages.
1461 \value PM_TabBarBaseOverlap Number of pixels the tab bar overlaps
1462 the tab bar base.
1463 \value PM_TabBarScrollButtonWidth
1464 \value PM_TabBarTabShiftHorizontal Horizontal pixel shift when a
1465 tab is selected.
1466 \value PM_TabBarTabShiftVertical Vertical pixel shift when a
1467 tab is selected.
1468
1469 \value PM_ProgressBarChunkWidth Width of a chunk in a progress bar indicator.
1470
1471 \value PM_SplitterWidth Width of a splitter.
1472
1473 \value PM_TitleBarHeight Height of the title bar.
1474
1475 \value PM_IndicatorWidth Width of a checkbox indicator.
1476 \value PM_IndicatorHeight Height of a checkbox indicator.
1477 \value PM_ExclusiveIndicatorWidth Width of a radio button indicator.
1478 \value PM_ExclusiveIndicatorHeight Height of a radio button indicator.
1479
1480 \value PM_MenuPanelWidth Border width (applied on all sides) for a QMenu.
1481 \value PM_MenuHMargin Additional border (used on left and right) for a QMenu.
1482 \value PM_MenuVMargin Additional border (used for bottom and top) for a QMenu.
1483 \value PM_MenuScrollerHeight Height of the scroller area in a QMenu.
1484 \value PM_MenuTearoffHeight Height of a tear off area in a QMenu.
1485 \value PM_MenuDesktopFrameWidth The frame width for the menu on the desktop.
1486
1487 \omitvalue PM_DialogButtonsSeparator
1488 \omitvalue PM_DialogButtonsButtonWidth
1489 \omitvalue PM_DialogButtonsButtonHeight
1490
1491 \value PM_HeaderMarkSize The size of the sort indicator in a header.
1492 \value PM_HeaderGripMargin The size of the resize grip in a header.
1493 \value PM_HeaderMargin The size of the margin between the sort indicator and the text.
1494 \value PM_SpinBoxSliderHeight The height of the optional spin box slider.
1495
1496 \value PM_ToolBarIconSize Default tool bar icon size
1497 \value PM_SmallIconSize Default small icon size
1498 \value PM_LargeIconSize Default large icon size
1499
1500 \value PM_FocusFrameHMargin Horizontal margin that the focus frame will outset the widget by.
1501 \value PM_FocusFrameVMargin Vertical margin that the focus frame will outset the widget by.
1502 \value PM_IconViewIconSize The default size for icons in an icon view.
1503 \value PM_ListViewIconSize The default size for icons in a list view.
1504
1505 \value PM_ToolTipLabelFrameWidth The frame width for a tool tip label.
1506 \value PM_CheckBoxLabelSpacing The spacing between a checkbox indicator and its label.
1507 \value PM_RadioButtonLabelSpacing The spacing between a radio button indicator and its label.
1508 \value PM_TabBarIconSize The default icon size for a tab bar.
1509 \value PM_SizeGripSize The size of a size grip.
1510 \value PM_MessageBoxIconSize The size of the standard icons in a message box
1511 \value PM_ButtonIconSize The default size of button icons
1512 \value PM_TextCursorWidth The width of the cursor in a line edit or text edit
1513 \value PM_TabBar_ScrollButtonOverlap The distance between the left and right buttons in a tab bar.
1514
1515 \value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar.
1516 \value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar.
1517
1518 \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
1519 with SH_ScrollView_FrameOnlyAroundContents set.
1520 \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content
1521
1522 \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
1523
1524 \value [since 5.4] PM_TreeViewIndentation The indentation of items in a tree view.
1525
1526 \value PM_HeaderDefaultSectionSizeHorizontal The default size of sections
1527 in a horizontal header. This enum value has been introduced in Qt 5.5.
1528 \value PM_HeaderDefaultSectionSizeVertical The default size of sections
1529 in a vertical header. This enum value has been introduced in Qt 5.5.
1530
1531 \value [since 5.8] PM_TitleBarButtonIconSize The size of button icons on a title bar.
1532 \value [since 5.8] PM_TitleBarButtonSize The size of buttons on a title bar.
1533
1534 \value [since 6.2] PM_LineEditIconSize The default size for icons in a line edit.
1535
1536 \value [since 6.3] PM_LineEditIconMargin The margin around icons in a line edit.
1537
1538 \value PM_CustomBase Base value for custom pixel metrics. Custom
1539 values must be greater than this value.
1540
1541 \sa pixelMetric()
1542*/
1543
1544/*!
1545 \fn int QStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const;
1546
1547 Returns the value of the given pixel \a metric.
1548
1549 The specified \a option and \a widget can be used for calculating
1550 the metric. The \a option can be cast to the appropriate type using the
1551 qstyleoption_cast() function. Note that the \a option may be zero
1552 even for PixelMetrics that can make use of it. See the table below
1553 for the appropriate \a option casts:
1554
1555 \table
1556 \header \li Pixel Metric \li QStyleOption Subclass
1557 \row \li \l PM_SliderControlThickness \li \l QStyleOptionSlider
1558 \row \li \l PM_SliderLength \li \l QStyleOptionSlider
1559 \row \li \l PM_SliderTickmarkOffset \li \l QStyleOptionSlider
1560 \row \li \l PM_SliderSpaceAvailable \li \l QStyleOptionSlider
1561 \row \li \l PM_ScrollBarExtent \li \l QStyleOptionSlider
1562 \row \li \l PM_TabBarTabOverlap \li \l QStyleOptionTab
1563 \row \li \l PM_TabBarTabHSpace \li \l QStyleOptionTab
1564 \row \li \l PM_TabBarTabVSpace \li \l QStyleOptionTab
1565 \row \li \l PM_TabBarBaseHeight \li \l QStyleOptionTab
1566 \row \li \l PM_TabBarBaseOverlap \li \l QStyleOptionTab
1567 \endtable
1568
1569 Some pixel metrics are called from widgets and some are only called
1570 internally by the style. If the metric is not called by a widget, it is the
1571 discretion of the style author to make use of it. For some styles, this
1572 may not be appropriate.
1573*/
1574
1575/*!
1576 \enum QStyle::ContentsType
1577
1578 This enum describes the available contents types. These are used to
1579 calculate sizes for the contents of various widgets.
1580
1581 \value CT_CheckBox A checkbox, like QCheckBox.
1582 \value CT_ComboBox A combo box, like QComboBox.
1583 \omitvalue CT_DialogButtons
1584 \value CT_HeaderSection A header section, like QHeader.
1585 \value CT_LineEdit A line edit, like QLineEdit.
1586 \value CT_Menu A menu, like QMenu.
1587 \value CT_MenuBar A menu bar, like QMenuBar.
1588 \value CT_MenuBarItem A menu bar item, like the buttons in a QMenuBar.
1589 \value CT_MenuItem A menu item, like QMenuItem.
1590 \value CT_ProgressBar A progress bar, like QProgressBar.
1591 \value CT_PushButton A push button, like QPushButton.
1592 \value CT_RadioButton A radio button, like QRadioButton.
1593 \value CT_SizeGrip A size grip, like QSizeGrip.
1594 \value CT_Slider A slider, like QSlider.
1595 \value CT_ScrollBar A scroll bar, like QScrollBar.
1596 \value CT_SpinBox A spin box, like QSpinBox.
1597 \value CT_Splitter A splitter, like QSplitter.
1598 \value CT_TabBarTab A tab on a tab bar, like QTabBar.
1599 \value CT_TabWidget A tab widget, like QTabWidget.
1600 \value CT_ToolButton A tool button, like QToolButton.
1601 \value CT_GroupBox A group box, like QGroupBox.
1602 \value CT_ItemViewItem An item inside an item view.
1603
1604 \value CT_CustomBase Base value for custom contents types.
1605 Custom values must be greater than this value.
1606
1607 \value CT_MdiControls The minimize, normal, and close button
1608 in the menu bar for a maximized MDI
1609 subwindow.
1610
1611 \sa sizeFromContents()
1612*/
1613
1614/*!
1615 \fn QSize QStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
1616
1617 Returns the size of the element described by the specified
1618 \a option and \a type, based on the provided \a contentsSize.
1619
1620 The \a option argument is a pointer to a QStyleOption or one of
1621 its subclasses. The \a option can be cast to the appropriate type
1622 using the qstyleoption_cast() function. The \a widget is an
1623 optional argument and can contain extra information used for
1624 calculating the size.
1625
1626 See the table below for the appropriate \a option casts:
1627
1628 \table
1629 \header \li Contents Type \li QStyleOption Subclass
1630 \row \li \l CT_CheckBox \li \l QStyleOptionButton
1631 \row \li \l CT_ComboBox \li \l QStyleOptionComboBox
1632 \row \li \l CT_GroupBox \li \l QStyleOptionGroupBox
1633 \row \li \l CT_HeaderSection \li \l QStyleOptionHeader
1634 \row \li \l CT_ItemViewItem \li \l QStyleOptionViewItem
1635 \row \li \l CT_LineEdit \li \l QStyleOptionFrame
1636 \row \li \l CT_MdiControls \li \l QStyleOptionComplex
1637 \row \li \l CT_Menu \li \l QStyleOption
1638 \row \li \l CT_MenuItem \li \l QStyleOptionMenuItem
1639 \row \li \l CT_MenuBar \li \l QStyleOptionMenuItem
1640 \row \li \l CT_MenuBarItem \li \l QStyleOptionMenuItem
1641 \row \li \l CT_ProgressBar \li \l QStyleOptionProgressBar
1642 \row \li \l CT_PushButton \li \l QStyleOptionButton
1643 \row \li \l CT_RadioButton \li \l QStyleOptionButton
1644 \row \li \l CT_ScrollBar \li \l QStyleOptionSlider
1645 \row \li \l CT_SizeGrip \li \l QStyleOption
1646 \row \li \l CT_Slider \li \l QStyleOptionSlider
1647 \row \li \l CT_SpinBox \li \l QStyleOptionSpinBox
1648 \row \li \l CT_Splitter \li \l QStyleOption
1649 \row \li \l CT_TabBarTab \li \l QStyleOptionTab
1650 \row \li \l CT_TabWidget \li \l QStyleOptionTabWidgetFrame
1651 \row \li \l CT_ToolButton \li \l QStyleOptionToolButton
1652 \endtable
1653
1654 \sa ContentsType, QStyleOption
1655*/
1656
1657/*!
1658 \enum QStyle::RequestSoftwareInputPanel
1659
1660 This enum describes under what circumstances a software input panel will be
1661 requested by input capable widgets.
1662
1663 \value RSIP_OnMouseClickAndAlreadyFocused Requests an input panel if the user
1664 clicks on the widget, but only if it is already focused.
1665 \value RSIP_OnMouseClick Requests an input panel if the user clicks on the
1666 widget.
1667
1668 \sa QInputMethod
1669*/
1670
1671/*!
1672 \enum QStyle::StyleHint
1673
1674 This enum describes the available style hints. A style hint is a general look
1675 and/or feel hint.
1676
1677 \value SH_EtchDisabledText Disabled text is "etched" as it is on Windows.
1678
1679 \value SH_DitherDisabledText Disabled text is dithered as it is on Motif.
1680
1681 \value SH_ScrollBar_ContextMenu Whether or not a scroll bar has a context menu.
1682
1683 \value SH_ScrollBar_MiddleClickAbsolutePosition A boolean value.
1684 If true, middle clicking on a scroll bar causes the slider to
1685 jump to that position. If false, middle clicking is
1686 ignored.
1687
1688 \value SH_ScrollBar_LeftClickAbsolutePosition A boolean value.
1689 If true, left clicking on a scroll bar causes the slider to
1690 jump to that position. If false, left clicking will
1691 behave as appropriate for each control.
1692
1693 \value SH_ScrollBar_ScrollWhenPointerLeavesControl A boolean
1694 value. If true, when clicking a scroll bar SubControl, holding
1695 the mouse button down and moving the pointer outside the
1696 SubControl, the scroll bar continues to scroll. If false, the
1697 scollbar stops scrolling when the pointer leaves the
1698 SubControl.
1699
1700 \value SH_ScrollBar_RollBetweenButtons A boolean value.
1701 If true, when clicking a scroll bar button (SC_ScrollBarAddLine or
1702 SC_ScrollBarSubLine) and dragging over to the opposite button (rolling)
1703 will press the new button and release the old one. When it is false, the
1704 original button is released and nothing happens (like a push button).
1705
1706 \value SH_TabBar_Alignment The alignment for tabs in a
1707 QTabWidget. Possible values are Qt::AlignLeft,
1708 Qt::AlignCenter and Qt::AlignRight.
1709
1710 \value SH_Header_ArrowAlignment The placement of the sorting
1711 indicator may appear in list or table headers. Possible values
1712 are Qt::Alignment values (that is, an OR combination of
1713 Qt::AlignmentFlag flags).
1714
1715 \value SH_Slider_SnapToValue Sliders snap to values while moving,
1716 as they do on Windows.
1717
1718 \value SH_Slider_SloppyKeyEvents Key presses handled in a sloppy
1719 manner, i.e., left on a vertical slider subtracts a line.
1720
1721 \value SH_ProgressDialog_CenterCancelButton Center button on
1722 progress dialogs, otherwise right aligned.
1723
1724 \value SH_ProgressDialog_TextLabelAlignment The alignment for text
1725 labels in progress dialogs; Qt::AlignCenter on Windows,
1726 Qt::AlignVCenter otherwise.
1727
1728 \value SH_PrintDialog_RightAlignButtons Right align buttons in
1729 the print dialog, as done on Windows.
1730
1731 \value SH_MainWindow_SpaceBelowMenuBar One or two pixel space between
1732 the menu bar and the dockarea, as done on Windows.
1733
1734 \value SH_FontDialog_SelectAssociatedText Select the text in the
1735 line edit, or when selecting an item from the listbox, or when
1736 the line edit receives focus, as done on Windows.
1737
1738 \value SH_Menu_KeyboardSearch Typing causes a menu to be search
1739 for relevant items, otherwise only mnemonic is considered.
1740
1741 \value SH_Menu_AllowActiveAndDisabled Allows disabled menu
1742 items to be active.
1743
1744 \value SH_Menu_SpaceActivatesItem Pressing the space bar activates
1745 the item, as done on Motif.
1746
1747 \value SH_Menu_SubMenuPopupDelay The number of milliseconds
1748 to wait before opening a submenu (256 on Windows, 96 on Motif).
1749
1750 \value SH_Menu_Scrollable Whether popup menus must support scrolling.
1751
1752 \value SH_Menu_SloppySubMenus Whether popup menus must support
1753 the user moving the mouse cursor to a submenu while crossing
1754 other items of the menu. This is supported on most modern
1755 desktop platforms.
1756
1757 \value SH_Menu_SubMenuUniDirection Since Qt 5.5. If the cursor has
1758 to move towards the submenu (like it is on \macos), or if the
1759 cursor can move in any direction as long as it reaches the
1760 submenu before the sloppy timeout.
1761
1762 \value SH_Menu_SubMenuUniDirectionFailCount Since Qt 5.5. When
1763 SH_Menu_SubMenuUniDirection is defined this enum defines the
1764 number of failed mouse moves before the sloppy submenu is
1765 discarded. This can be used to control the "strictness" of the
1766 uni direction algorithm.
1767
1768 \value SH_Menu_SubMenuSloppySelectOtherActions Since Qt 5.5. Should
1769 other action items be selected when the mouse moves towards a
1770 sloppy submenu.
1771
1772 \value SH_Menu_SubMenuSloppyCloseTimeout Since Qt 5.5. The timeout
1773 used to close sloppy submenus.
1774
1775 \value SH_Menu_SubMenuResetWhenReenteringParent Since Qt 5.5. When
1776 entering parent from child submenu, should the sloppy state be
1777 reset, effectively closing the child and making the current
1778 submenu active.
1779
1780 \value SH_Menu_SubMenuDontStartSloppyOnLeave Since Qt 5.5. Do not
1781 start sloppy timers when the mouse leaves a sub-menu.
1782
1783 \value SH_ScrollView_FrameOnlyAroundContents Whether scrollviews
1784 draw their frame only around contents (like Motif), or around
1785 contents, scroll bars and corner widgets (like Windows).
1786
1787 \value SH_MenuBar_AltKeyNavigation Menu bars items are navigable
1788 by pressing Alt, followed by using the arrow keys to select
1789 the desired item.
1790
1791 \value SH_ComboBox_ListMouseTracking_Current Mouse tracking in
1792 combobox drop-down lists, the item under the cursor is made
1793 the current item (QStyle::State_Selected).
1794
1795 \value SH_ComboBox_ListMouseTracking Deprecated. Use
1796 \l{SH_ComboBox_ListMouseTracking_Current} instead.
1797
1798 \value SH_ComboBox_ListMouseTracking_Active Mouse tracking in
1799 combobox drop-down lists, the item under the cursor is not
1800 made the current item, only active (QStyle::State_MouseOver).
1801
1802 \value SH_Menu_MouseTracking Mouse tracking in popup menus.
1803
1804 \value SH_MenuBar_MouseTracking Mouse tracking in menu bars.
1805
1806 \value SH_Menu_FillScreenWithScroll Whether scrolling popups
1807 should fill the screen as they are scrolled.
1808
1809 \value SH_Menu_SelectionWrap Whether popups should allow the selections
1810 to wrap, that is when selection should the next item be the first item.
1811
1812 \value SH_ItemView_ChangeHighlightOnFocus Gray out selected items
1813 when losing focus.
1814
1815 \value SH_Widget_ShareActivation Turn on sharing activation with
1816 floating modeless dialogs.
1817
1818 \value SH_TabBar_SelectMouseType Which type of mouse event should
1819 cause a tab to be selected.
1820
1821 \value SH_ListViewExpand_SelectMouseType Which type of mouse event should
1822 cause a list view expansion to be selected.
1823
1824 \value SH_TabBar_PreferNoArrows Whether a tab bar should suggest a size
1825 to prevent scroll arrows.
1826
1827 \value SH_ComboBox_Popup Allows popups as a combobox drop-down
1828 menu.
1829
1830 \omitvalue SH_ComboBox_UseNativePopup
1831
1832 \value SH_Workspace_FillSpaceOnMaximize The workspace should
1833 maximize the client area.
1834
1835 \value SH_TitleBar_NoBorder The title bar has no border.
1836
1837 \value SH_Slider_StopMouseOverSlider Stops auto-repeat when
1838 the slider reaches the mouse position.
1839
1840 \value SH_BlinkCursorWhenTextSelected Whether cursor should blink
1841 when text is selected.
1842
1843 \value SH_RichText_FullWidthSelection Whether richtext selections
1844 should extend to the full width of the document.
1845
1846 \value SH_GroupBox_TextLabelVerticalAlignment How to vertically align a
1847 group box's text label.
1848
1849 \value SH_GroupBox_TextLabelColor How to paint a group box's text label.
1850
1851 \value SH_DialogButtons_DefaultButton Which button gets the
1852 default status in a dialog's button widget.
1853
1854 \value SH_ToolBox_SelectedPageTitleBold Boldness of the selected
1855 page title in a QToolBox.
1856
1857 \value SH_LineEdit_PasswordCharacter The Unicode character to be
1858 used for passwords.
1859
1860 \value SH_LineEdit_PasswordMaskDelay Determines the delay before visible character is masked
1861 with password character, in milliseconds. This enum value was added in Qt 5.4.
1862
1863 \value SH_Table_GridLineColor The RGBA value of the grid for a table.
1864
1865 \value SH_UnderlineShortcut Whether shortcuts are underlined.
1866
1867 \value SH_SpinBox_AnimateButton Animate a click when up or down is
1868 pressed in a spin box.
1869 \value SH_SpinBox_KeyPressAutoRepeatRate Auto-repeat interval for
1870 spinbox key presses.
1871 \value SH_SpinBox_ClickAutoRepeatRate Auto-repeat interval for
1872 spinbox mouse clicks.
1873 \value SH_SpinBox_ClickAutoRepeatThreshold Auto-repeat threshold for
1874 spinbox mouse clicks.
1875 \value [since 6.3] SH_SpinBox_SelectOnStep Whether changing the value using
1876 the buttons or up/down keys automatically selects the text.
1877
1878 \value SH_ToolTipLabel_Opacity An integer indicating the opacity for
1879 the tip label, 0 is completely transparent, 255 is completely
1880 opaque.
1881 \value SH_DrawMenuBarSeparator Indicates whether or not the menu bar draws separators.
1882 \value SH_TitleBar_ModifyNotification Indicates if the title bar should show
1883 a '*' for windows that are modified.
1884
1885 \value SH_Button_FocusPolicy The default focus policy for buttons.
1886
1887 \value SH_CustomBase Base value for custom style hints.
1888 Custom values must be greater than this value.
1889
1890 \value SH_MessageBox_UseBorderForButtonSpacing A boolean indicating what the to
1891 use the border of the buttons (computed as half the button height) for the spacing
1892 of the button in a message box.
1893
1894 \value SH_MessageBox_CenterButtons A boolean indicating whether the buttons in the
1895 message box should be centered or not (see QDialogButtonBox::setCentered()).
1896
1897 \value SH_MessageBox_TextInteractionFlags A boolean indicating if
1898 the text in a message box should allow user interactions (e.g.
1899 selection) or not.
1900
1901 \value SH_TitleBar_AutoRaise A boolean indicating whether
1902 controls on a title bar ought to update when the mouse is over them.
1903
1904 \value SH_ToolButton_PopupDelay An int indicating the popup delay in milliseconds
1905 for menus attached to tool buttons.
1906
1907 \value SH_FocusFrame_Mask The mask of the focus frame.
1908
1909 \value SH_RubberBand_Mask The mask of the rubber band.
1910
1911 \value SH_WindowFrame_Mask The mask of the window frame.
1912
1913 \value SH_SpinControls_DisableOnBounds Determines if the spin controls will shown
1914 as disabled when reaching the spin range boundary.
1915
1916 \value SH_Dial_BackgroundRole Defines the style's preferred
1917 background role (as QPalette::ColorRole) for a dial widget.
1918
1919 \value SH_ComboBox_LayoutDirection The layout direction for the
1920 combo box. By default it should be the same as indicated by the
1921 QStyleOption::direction variable.
1922
1923 \value SH_ItemView_EllipsisLocation The location where ellipses should be
1924 added for item text that is too long to fit in an view item.
1925
1926 \value SH_ItemView_ShowDecorationSelected When an item in an item
1927 view is selected, also highlight the branch or other decoration.
1928
1929 \value SH_ItemView_ActivateItemOnSingleClick Emit the activated signal
1930 when the user single clicks on an item in an item in an item view.
1931 Otherwise the signal is emitted when the user double clicks on an item.
1932
1933 \value SH_Slider_AbsoluteSetButtons Which mouse buttons cause a slider
1934 to set the value to the position clicked on.
1935
1936 \value SH_Slider_PageSetButtons Which mouse buttons cause a slider
1937 to page step the value.
1938
1939 \value SH_TabBar_ElideMode The default eliding style for a tab bar.
1940
1941 \value SH_DialogButtonLayout Controls how buttons are laid out in a QDialogButtonBox, returns a QDialogButtonBox::ButtonLayout enum.
1942
1943 \value SH_WizardStyle Controls the look and feel of a QWizard. Returns a QWizard::WizardStyle enum.
1944
1945 \value SH_FormLayoutWrapPolicy Provides a default for how rows are wrapped in a QFormLayout. Returns a QFormLayout::RowWrapPolicy enum.
1946 \value SH_FormLayoutFieldGrowthPolicy Provides a default for how fields can grow in a QFormLayout. Returns a QFormLayout::FieldGrowthPolicy enum.
1947 \value SH_FormLayoutFormAlignment Provides a default for how a QFormLayout aligns its contents within the available space. Returns a Qt::Alignment enum.
1948 \value SH_FormLayoutLabelAlignment Provides a default for how a QFormLayout aligns labels within the available space. Returns a Qt::Alignment enum.
1949
1950 \value SH_ItemView_ArrowKeysNavigateIntoChildren Controls whether the tree view will select the first child when it is exapanded and the right arrow key is pressed.
1951 \value SH_ComboBox_PopupFrameStyle The frame style used when drawing a combobox popup menu.
1952
1953 \value SH_DialogButtonBox_ButtonsHaveIcons Indicates whether or not StandardButtons in QDialogButtonBox should have icons or not.
1954 \value SH_ItemView_MovementWithoutUpdatingSelection The item view is able to indicate a current item without changing the selection.
1955 \value SH_ToolTip_Mask The mask of a tool tip.
1956
1957 \value SH_FocusFrame_AboveWidget The FocusFrame is stacked above the widget that it is "focusing on".
1958
1959 \value SH_TextControl_FocusIndicatorTextCharFormat Specifies the text format used to highlight focused anchors in rich text
1960 documents displayed for example in QTextBrowser. The format has to be a QTextCharFormat returned in the variant of the
1961 QStyleHintReturnVariant return value. The QTextFormat::OutlinePen property is used for the outline and QTextFormat::BackgroundBrush
1962 for the background of the highlighted area.
1963
1964 \value SH_Menu_FlashTriggeredItem Flash triggered item.
1965 \value SH_Menu_FadeOutOnHide Fade out the menu instead of hiding it immediately.
1966
1967 \value SH_TabWidget_DefaultTabPosition Default position of the tab bar in a tab widget.
1968
1969 \value SH_ToolBar_Movable Determines if the tool bar is movable by default.
1970
1971 \value SH_ItemView_PaintAlternatingRowColorsForEmptyArea Whether QTreeView paints alternating row colors for the area that does not have any items.
1972
1973 \value SH_Menu_Mask The mask for a popup menu.
1974
1975 \value SH_ItemView_DrawDelegateFrame Determines if there should be a frame for a delegate widget.
1976
1977 \value SH_TabBar_CloseButtonPosition Determines the position of the close button on a tab in a tab bar.
1978
1979 \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true.
1980
1981 \value SH_ToolButtonStyle Determines the default system style for tool buttons that uses Qt::ToolButtonFollowStyle.
1982
1983 \value SH_RequestSoftwareInputPanel Determines when a software input panel should
1984 be requested by input widgets. Returns an enum of type QStyle::RequestSoftwareInputPanel.
1985
1986 \value SH_ScrollBar_Transient Determines if the style supports transient scroll bars. Transient
1987 scroll bars appear when the content is scrolled and disappear when they are no longer needed.
1988
1989 \value SH_Menu_SupportsSections Determines if the style displays sections in menus or treat them as
1990 plain separators. Sections are separators with a text and icon hint.
1991
1992 \value SH_ToolTip_WakeUpDelay Determines the delay before a tooltip is shown, in milliseconds.
1993
1994 \value SH_ToolTip_FallAsleepDelay Determines the delay (in milliseconds) before a new wake time is needed when
1995 a tooltip is shown (notice: shown, not hidden). When a new wake isn't needed, a user-requested tooltip
1996 will be shown nearly instantly.
1997
1998 \value SH_Widget_Animate Deprecated. Use \l{SH_Widget_Animation_Duration} instead.
1999
2000 \value SH_Splitter_OpaqueResize Determines if widgets are resized dynamically (opaquely) while
2001 interactively moving the splitter. This enum value was introduced in Qt 5.2.
2002
2003 \value SH_TabBar_ChangeCurrentDelay Determines the delay before the current
2004 tab is changed while dragging over the tabbar, in milliseconds. This
2005 enum value has been introduced in Qt 5.4
2006
2007 \value SH_ItemView_ScrollMode The default vertical and horizontal scroll mode as specified
2008 by the style. Can be overridden with QAbstractItemView::setVerticalScrollMode() and
2009 QAbstractItemView::setHorizontalScrollMode(). This enum value has been introduced in Qt 5.7.
2010
2011 \value SH_TitleBar_ShowToolTipsOnButtons
2012 Determines if tool tips are shown on window title bar buttons.
2013 The Mac style, for example, sets this to false.
2014 This enum value has been introduced in Qt 5.10.
2015
2016 \value SH_Widget_Animation_Duration
2017 Determines how much an animation should last (in ms).
2018 A value equal to zero means that the animations will be disabled.
2019 This enum value has been introduced in Qt 5.10.
2020
2021 \value SH_ComboBox_AllowWheelScrolling
2022 Determines if the mouse wheel can be used to scroll inside a QComboBox.
2023 This is on by default in all styles except the Mac style.
2024 This enum value has been introduced in Qt 5.10.
2025
2026 \value SH_SpinBox_ButtonsInsideFrame
2027 Determines if the spin box buttons are inside the line edit frame.
2028 This enum value has been introduced in Qt 5.11.
2029
2030 \value SH_SpinBox_StepModifier
2031 Determines which Qt::KeyboardModifier increases the step rate of
2032 QAbstractSpinBox. Possible values are Qt::NoModifier,
2033 Qt::ControlModifier (default) or Qt::ShiftModifier. Qt::NoModifier
2034 disables this feature.
2035 This enum value has been introduced in Qt 5.12.
2036
2037 \value SH_TabBar_AllowWheelScrolling
2038 Determines if the mouse wheel can be used to cycle through the tabs
2039 of a QTabBar.
2040 This enum value has been introduced in Qt 6.1.
2041
2042 \value SH_Table_AlwaysDrawLeftTopGridLines
2043 Determines if the far left and top grid lines are drawn in a table or
2044 not when the header is hidden. Defaults to false.
2045 This enum value has been introduced in Qt 6.3.
2046
2047 \sa styleHint()
2048*/
2049
2050/*!
2051 \fn int QStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
2052
2053 Returns an integer representing the specified style \a hint for
2054 the given \a widget described by the provided style \a option.
2055
2056 \a returnData is used when the querying widget needs more detailed data than
2057 the integer that styleHint() returns. See the QStyleHintReturn class
2058 description for details.
2059*/
2060
2061/*!
2062 \enum QStyle::StandardPixmap
2063
2064 This enum describes the available standard pixmaps. A standard pixmap is a pixmap that
2065 can follow some existing GUI style or guideline.
2066
2067 \value SP_TitleBarMinButton Minimize button on title bars (e.g.,
2068 in QMdiSubWindow).
2069 \value SP_TitleBarMenuButton Menu button on a title bar.
2070 \value SP_TitleBarMaxButton Maximize button on title bars.
2071 \value SP_TitleBarCloseButton Close button on title bars.
2072 \value SP_TitleBarNormalButton Normal (restore) button on title bars.
2073 \value SP_TitleBarShadeButton Shade button on title bars.
2074 \value SP_TitleBarUnshadeButton Unshade button on title bars.
2075 \value SP_TitleBarContextHelpButton The Context help button on title bars.
2076 \value SP_MessageBoxInformation The "information" icon.
2077 \value SP_MessageBoxWarning The "warning" icon.
2078 \value SP_MessageBoxCritical The "critical" icon.
2079 \value SP_MessageBoxQuestion The "question" icon.
2080 \value SP_DesktopIcon The "desktop" icon.
2081 \value SP_TrashIcon The "trash" icon.
2082 \value SP_ComputerIcon The "My computer" icon.
2083 \value SP_DriveFDIcon The floppy icon.
2084 \value SP_DriveHDIcon The harddrive icon.
2085 \value SP_DriveCDIcon The CD icon.
2086 \value SP_DriveDVDIcon The DVD icon.
2087 \value SP_DriveNetIcon The network icon.
2088 \value SP_DirHomeIcon The home directory icon.
2089 \value SP_DirOpenIcon The open directory icon.
2090 \value SP_DirClosedIcon The closed directory icon.
2091 \value SP_DirIcon The directory icon.
2092 \value SP_DirLinkIcon The link to directory icon.
2093 \value SP_DirLinkOpenIcon The link to open directory icon.
2094 \value SP_FileIcon The file icon.
2095 \value SP_FileLinkIcon The link to file icon.
2096 \value SP_FileDialogStart The "start" icon in a file dialog.
2097 \value SP_FileDialogEnd The "end" icon in a file dialog.
2098 \value SP_FileDialogToParent The "parent directory" icon in a file dialog.
2099 \value SP_FileDialogNewFolder The "create new folder" icon in a file dialog.
2100 \value SP_FileDialogDetailedView The detailed view icon in a file dialog.
2101 \value SP_FileDialogInfoView The file info icon in a file dialog.
2102 \value SP_FileDialogContentsView The contents view icon in a file dialog.
2103 \value SP_FileDialogListView The list view icon in a file dialog.
2104 \value SP_FileDialogBack The back arrow in a file dialog.
2105 \value SP_DockWidgetCloseButton Close button on dock windows (see also QDockWidget).
2106 \value SP_ToolBarHorizontalExtensionButton Extension button for horizontal toolbars.
2107 \value SP_ToolBarVerticalExtensionButton Extension button for vertical toolbars.
2108 \value SP_DialogOkButton Icon for a standard OK button in a QDialogButtonBox.
2109 \value SP_DialogCancelButton Icon for a standard Cancel button in a QDialogButtonBox.
2110 \value SP_DialogHelpButton Icon for a standard Help button in a QDialogButtonBox.
2111 \value SP_DialogOpenButton Icon for a standard Open button in a QDialogButtonBox.
2112 \value SP_DialogSaveButton Icon for a standard Save button in a QDialogButtonBox.
2113 \value SP_DialogCloseButton Icon for a standard Close button in a QDialogButtonBox.
2114 \value SP_DialogApplyButton Icon for a standard Apply button in a QDialogButtonBox.
2115 \value SP_DialogResetButton Icon for a standard Reset button in a QDialogButtonBox.
2116 \value SP_DialogDiscardButton Icon for a standard Discard button in a QDialogButtonBox.
2117 \value SP_DialogYesButton Icon for a standard Yes button in a QDialogButtonBox.
2118 \value SP_DialogNoButton Icon for a standard No button in a QDialogButtonBox.
2119 \value SP_ArrowUp Icon arrow pointing up.
2120 \value SP_ArrowDown Icon arrow pointing down.
2121 \value SP_ArrowLeft Icon arrow pointing left.
2122 \value SP_ArrowRight Icon arrow pointing right.
2123 \value SP_ArrowBack Equivalent to SP_ArrowLeft when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowRight.
2124 \value SP_ArrowForward Equivalent to SP_ArrowRight when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowLeft.
2125 \value SP_CommandLink Icon used to indicate a Vista style command link glyph.
2126 \value SP_VistaShield Icon used to indicate UAC prompts on Windows Vista. This will return a null pixmap or icon on all other platforms.
2127 \value SP_BrowserReload Icon indicating that the current page should be reloaded.
2128 \value SP_BrowserStop Icon indicating that the page loading should stop.
2129 \value SP_MediaPlay Icon indicating that media should begin playback.
2130 \value SP_MediaStop Icon indicating that media should stop playback.
2131 \value SP_MediaPause Icon indicating that media should pause playback.
2132 \value SP_MediaSkipForward Icon indicating that media should skip forward.
2133 \value SP_MediaSkipBackward Icon indicating that media should skip backward.
2134 \value SP_MediaSeekForward Icon indicating that media should seek forward.
2135 \value SP_MediaSeekBackward Icon indicating that media should seek backward.
2136 \value SP_MediaVolume Icon indicating a volume control.
2137 \value SP_MediaVolumeMuted Icon indicating a muted volume control.
2138 \value [since 5.2] SP_LineEditClearButton Icon for a standard clear button in a QLineEdit.
2139 \value [since 5.14] SP_DialogYesToAllButton Icon for a standard YesToAll button in a QDialogButtonBox.
2140 \value [since 5.14] SP_DialogNoToAllButton Icon for a standard NoToAll button in a QDialogButtonBox.
2141 \value [since 5.14] SP_DialogSaveAllButton Icon for a standard SaveAll button in a QDialogButtonBox.
2142 \value [since 5.14] SP_DialogAbortButton Icon for a standard Abort button in a QDialogButtonBox.
2143 \value [since 5.14] SP_DialogRetryButton Icon for a standard Retry button in a QDialogButtonBox.
2144 \value [since 5.14] SP_DialogIgnoreButton Icon for a standard Ignore button in a QDialogButtonBox.
2145 \value [since 5.14] SP_RestoreDefaultsButton Icon for a standard RestoreDefaults button in a QDialogButtonBox.
2146 \value [since 6.3] SP_TabCloseButton Icon for the close button in the tab of a QTabBar.
2147 \value [since 6.12] SP_TabScrollLeftButton Icon for the scroll left button of a QTabBar.
2148 \value [since 6.12] SP_TabScrollRightButton Icon for the scroll right button of a QTabBar.
2149 \value [since 6.12] SP_TabScrollUpButton Icon for the scroll up button of a QTabBar.
2150 \value [since 6.12] SP_TabScrollDownButton Icon for the scroll down button of a QTabBar.
2151 \omitvalue NStandardPixmap
2152 \value SP_CustomBase Base value for custom standard pixmaps;
2153 custom values must be greater than this value.
2154
2155 \sa standardIcon()
2156*/
2157
2158/*!
2159 \fn QPixmap QStyle::generatedIconPixmap(QIcon::Mode iconMode,
2160 const QPixmap &pixmap, const QStyleOption *option) const
2161
2162 Returns a copy of the given \a pixmap, styled to conform to the
2163 specified \a iconMode and taking into account the palette
2164 specified by \a option.
2165
2166 The \a option parameter can pass extra information, but
2167 it must contain a palette.
2168
2169 Note that not all pixmaps will conform, in which case the returned
2170 pixmap is a plain copy.
2171
2172 \sa QIcon
2173*/
2174
2175/*!
2176 \fn QPixmap QStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const
2177
2178 \deprecated
2179 Returns a pixmap for the given \a standardPixmap.
2180
2181 A standard pixmap is a pixmap that can follow some existing GUI
2182 style or guideline. The \a option argument can be used to pass
2183 extra information required when defining the appropriate
2184 pixmap. The \a widget argument is optional and can also be used to
2185 aid the determination of the pixmap.
2186
2187 Developers calling standardPixmap() should instead call standardIcon()
2188 Developers who re-implemented standardPixmap() should instead re-implement
2189 standardIcon().
2190
2191 \sa standardIcon()
2192*/
2193
2194
2195/*!
2196 \fn QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QRect &logicalRectangle)
2197
2198 Returns the given \a logicalRectangle converted to screen
2199 coordinates based on the specified \a direction. The \a
2200 boundingRectangle is used when performing the translation.
2201
2202 This function is provided to support right-to-left desktops, and
2203 is typically used in implementations of the subControlRect()
2204 function.
2205
2206 \sa QWidget::layoutDirection
2207*/
2208QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
2209{
2210 if (direction == Qt::LeftToRight)
2211 return logicalRect;
2212 QRect rect = logicalRect;
2213 rect.translate(2 * (boundingRect.right() - logicalRect.right()) +
2214 logicalRect.width() - boundingRect.width(), 0);
2215 return rect;
2216}
2217
2218/*!
2219 \fn QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QPoint &logicalPosition)
2220
2221 Returns the given \a logicalPosition converted to screen
2222 coordinates based on the specified \a direction. The \a
2223 boundingRectangle is used when performing the translation.
2224
2225 \sa QWidget::layoutDirection
2226*/
2227QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
2228{
2229 if (direction == Qt::LeftToRight)
2230 return logicalPos;
2231 return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
2232}
2233
2234/*!
2235 Returns a new rectangle of the specified \a size that is aligned to the given \a
2236 rectangle according to the specified \a alignment and \a direction.
2237 */
2238QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
2239{
2240 alignment = visualAlignment(direction, alignment);
2241 int x = rectangle.x();
2242 int y = rectangle.y();
2243 int w = size.width();
2244 int h = size.height();
2245 if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
2246 y += rectangle.size().height()/2 - h/2;
2247 else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
2248 y += rectangle.size().height() - h;
2249 if ((alignment & Qt::AlignRight) == Qt::AlignRight)
2250 x += rectangle.size().width() - w;
2251 else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
2252 x += rectangle.size().width()/2 - w/2;
2253 return QRect(x, y, w, h);
2254}
2255
2256/*!
2257 Transforms an \a alignment of Qt::AlignLeft or Qt::AlignRight
2258 without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with
2259 Qt::AlignAbsolute according to the layout \a direction. The other
2260 alignment flags are left untouched.
2261
2262 If no horizontal alignment was specified, the function returns the
2263 default alignment for the given layout \a direction.
2264
2265 QWidget::layoutDirection
2266*/
2267Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
2268{
2269 return QGuiApplicationPrivate::visualAlignment(direction, alignment);
2270}
2271
2272/*!
2273 Converts the given \a logicalValue to a pixel position. The \a min
2274 parameter maps to 0, \a max maps to \a span and other values are
2275 distributed evenly in-between.
2276
2277 This function can handle the entire integer range without
2278 overflow, providing that \a span is less than 4096.
2279
2280 By default, this function assumes that the maximum value is on the
2281 right for horizontal items and on the bottom for vertical items.
2282 Set the \a upsideDown parameter to true to reverse this behavior.
2283
2284 \sa sliderValueFromPosition()
2285*/
2286
2287int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown)
2288{
2289 if (span <= 0 || max <= min)
2290 return 0;
2291 if (logicalValue < min)
2292 return upsideDown ? span : 0;
2293 if (logicalValue > max)
2294 return upsideDown ? 0 : span;
2295
2296 const uint range = qint64(max) - min;
2297 const uint p = upsideDown ? qint64(max) - logicalValue : qint64(logicalValue) - min;
2298
2299 if (range > (uint)INT_MAX/4096) {
2300 double dpos = (double(p))/(double(range)/span);
2301 return int(dpos);
2302 } else if (q20::cmp_greater(range, span)) {
2303 return (2 * p * span + range) / (2*range);
2304 } else {
2305 uint div = span / range;
2306 uint mod = span % range;
2307 return p * div + (2 * p * mod + range) / (2 * range);
2308 }
2309 // equiv. to (p * span) / range + 0.5
2310 // no overflow because of this implicit assumption:
2311 // span <= 4096
2312}
2313
2314/*!
2315 \fn int QStyle::sliderValueFromPosition(int min, int max, int position, int span, bool upsideDown)
2316
2317 Converts the given pixel \a position to a logical value. 0 maps to
2318 the \a min parameter, \a span maps to \a max and other values are
2319 distributed evenly in-between.
2320
2321 This function can handle the entire integer range without
2322 overflow.
2323
2324 By default, this function assumes that the maximum value is on the
2325 right for horizontal items and on the bottom for vertical
2326 items. Set the \a upsideDown parameter to true to reverse this
2327 behavior.
2328
2329 \sa sliderPositionFromValue()
2330*/
2331
2332int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown)
2333{
2334 if (span <= 0 || pos <= 0)
2335 return upsideDown ? max : min;
2336 if (pos >= span)
2337 return upsideDown ? min : max;
2338
2339 const qint64 range = qint64(max) - min;
2340
2341 if (q20::cmp_greater(span, range)) {
2342 const int tmp = (2 * range * pos + span) / (qint64(2) * span);
2343 return upsideDown ? max - tmp : tmp + min;
2344 } else {
2345 const qint64 div = range / span;
2346 const qint64 mod = range % span;
2347 const int tmp = pos * div + (2 * mod * pos + span) / (qint64(2) * span);
2348 return upsideDown ? max - tmp : tmp + min;
2349 }
2350 // equiv. to min + (pos*range)/span + 0.5
2351 // no overflow because of this implicit assumption:
2352 // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX)
2353}
2354
2355/*!
2356 Returns the style's standard palette.
2357
2358 Note that on systems that support system colors, the style's
2359 standard palette is not used. In particular, the Windows
2360 Vista and Mac styles do not use the standard palette, but make
2361 use of native theme engines. With these styles, you should not set
2362 the palette with QApplication::setPalette().
2363
2364 \sa QApplication::setPalette()
2365 */
2366QPalette QStyle::standardPalette() const
2367{
2368 QColor background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
2369
2370 QColor light(background.lighter());
2371 QColor dark(background.darker());
2372 QColor mid(Qt::gray);
2373 QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
2374 palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
2375 palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
2376 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
2377 palette.setBrush(QPalette::Disabled, QPalette::Base, background);
2378 return palette;
2379}
2380
2381/*!
2382 \since 4.1
2383
2384 \fn QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr,
2385 const QWidget *widget = nullptr) const = 0;
2386
2387 Returns an icon for the given \a standardIcon.
2388
2389 The \a standardIcon is a standard pixmap which can follow some
2390 existing GUI style or guideline. The \a option argument can be
2391 used to pass extra information required when defining the
2392 appropriate icon. The \a widget argument is optional and can also
2393 be used to aid the determination of the icon.
2394*/
2395
2396/*!
2397 \since 4.3
2398
2399 \fn int QStyle::layoutSpacing(QSizePolicy::ControlType control1,
2400 QSizePolicy::ControlType control2, Qt::Orientation orientation,
2401 const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const
2402
2403 Returns the spacing that should be used between \a control1 and
2404 \a control2 in a layout. \a orientation specifies whether the
2405 controls are laid out side by side or stacked vertically. The \a
2406 option parameter can be used to pass extra information about the
2407 parent widget. The \a widget parameter is optional and can also
2408 be used if \a option is \nullptr.
2409
2410 This function is called by the layout system. It is used only if
2411 PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
2412 negative value.
2413
2414 \sa combinedLayoutSpacing()
2415*/
2416
2417/*!
2418 \since 4.3
2419
2420 Returns the spacing that should be used between \a controls1 and
2421 \a controls2 in a layout. \a orientation specifies whether the
2422 controls are laid out side by side or stacked vertically. The \a
2423 option parameter can be used to pass extra information about the
2424 parent widget. The \a widget parameter is optional and can also
2425 be used if \a option is \nullptr.
2426
2427 \a controls1 and \a controls2 are OR-combination of zero or more
2428 \l{QSizePolicy::ControlTypes}{control types}.
2429
2430 This function is called by the layout system. It is used only if
2431 PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
2432 negative value.
2433
2434 \sa layoutSpacing()
2435*/
2436int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
2437 QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
2438 QStyleOption *option, QWidget *widget) const
2439{
2440 QSizePolicy::ControlType array1[MaxBits];
2441 QSizePolicy::ControlType array2[MaxBits];
2442 int count1 = unpackControlTypes(controls1, array1);
2443 int count2 = unpackControlTypes(controls2, array2);
2444 int result = -1;
2445
2446 for (int i = 0; i < count1; ++i) {
2447 for (int j = 0; j < count2; ++j) {
2448 int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget);
2449 result = qMax(spacing, result);
2450 }
2451 }
2452 return result;
2453}
2454
2455/*!
2456 \since 4.6
2457
2458 \fn const QStyle *QStyle::proxy() const
2459
2460 This function returns the current proxy for this style.
2461 By default most styles will return themselves. However
2462 when a proxy style is in use, it will allow the style to
2463 call back into its proxy.
2464*/
2465const QStyle * QStyle::proxy() const
2466{
2467 Q_D(const QStyle);
2468 return d->proxyStyle == this ? this : d->proxyStyle->proxy();
2469}
2470
2471/* \internal
2472
2473 This function sets the base style that style calls will be
2474 redirected to. Note that ownership is not transferred. \a style
2475 must be a valid pointer (not nullptr).
2476*/
2477void QStyle::setProxy(QStyle *style)
2478{
2479 Q_D(QStyle);
2480 Q_ASSERT(style);
2481 d->proxyStyle = style;
2482}
2483
2484//Windows and KDE allow menus to cover the taskbar, while GNOME and macOS don't
2485bool QStylePrivate::useFullScreenForPopup()
2486{
2487 auto theme = QGuiApplicationPrivate::platformTheme();
2488 return theme && theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
2489}
2490
2491//
2492// QCachedPainter
2493QSet<QString> QCachedPainter::s_pixmapCacheKeys;
2494QCachedPainter::QCachedPainter(QPainter *painter, const QString &cachePrefix,
2495 const QStyleOption *option, QSize size, QRect paintRect)
2496 : m_painter(painter)
2497 , m_option(option)
2498 , m_paintRect(paintRect)
2499{
2500 const auto sz = size.isEmpty() ? option->rect.size() : size;
2501 const qreal dpr = QStyleHelper::getDpr(painter);
2502 m_pixmapName = QStyleHelper::uniqueName(cachePrefix, option, sz, dpr);
2503 m_alreadyCached = QPixmapCache::find(m_pixmapName, &m_pixmap);
2504 if (!m_alreadyCached) {
2505 m_pixmap = styleCachePixmap(sz, dpr);
2506 m_pixmapPainter = std::make_unique<QPainter>(&m_pixmap);
2507 m_pixmapPainter->setRenderHints(painter->renderHints());
2508 s_pixmapCacheKeys += m_pixmapName;
2509 }
2510}
2511
2512QCachedPainter::~QCachedPainter()
2513{
2514 finish();
2515 if (!m_alreadyCached)
2516 QPixmapCache::insert(m_pixmapName, m_pixmap);
2517}
2518
2519void QCachedPainter::finish()
2520{
2521 m_pixmapPainter.reset();
2522 if (!m_pixmapDrawn) {
2523 m_pixmapDrawn = true;
2524 if (m_paintRect.isNull())
2525 m_painter->drawPixmap(m_option->rect.topLeft(), m_pixmap);
2526 else
2527 m_painter->drawPixmap(m_paintRect, m_pixmap);
2528 }
2529}
2530
2531void QCachedPainter::cleanupPixmapCache()
2532{
2533 for (const auto &key : s_pixmapCacheKeys)
2534 QPixmapCache::remove(key);
2535 s_pixmapCacheKeys.clear();
2536}
2537
2538QT_END_NAMESPACE
2539
2540#include "moc_qstyle.cpp"
static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)
Definition qstyle.cpp:29
static QT_BEGIN_NAMESPACE const int MaxBits
Definition qstyle.cpp:27