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