1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include <QtWidgets/private/qtwidgetsglobal_p.h>
41#include "private/qstylehelper_p.h"
42#include "qstyleoption.h"
43#include "qapplication.h"
44#include <qdebug.h>
45#include <QtCore/qmath.h>
46
47QT_BEGIN_NAMESPACE
48
49/*!
50 \class QStyleOption
51 \brief The QStyleOption class stores the parameters used by QStyle functions.
52
53 \ingroup appearance
54 \inmodule QtWidgets
55
56 QStyleOption and its subclasses contain all the information that
57 QStyle functions need to draw a graphical element.
58
59 For performance reasons, there are few member functions and the
60 access to the member variables is direct (i.e., using the \c . or
61 \c -> operator). This makes the structures straightforward to use
62 and emphasizes that these are simply parameters used by the style
63 functions.
64
65 The caller of a QStyle function usually creates QStyleOption
66 objects on the stack. This combined with Qt's extensive use of
67 \l{implicit sharing} for types such as QString, QPalette, and
68 QColor ensures that no memory allocation needlessly takes place.
69
70 The following code snippet shows how to use a specific
71 QStyleOption subclass to paint a push button:
72
73 \snippet qstyleoption/main.cpp 0
74
75 In our example, the control is a QStyle::CE_PushButton, and
76 according to the QStyle::drawControl() documentation the
77 corresponding class is QStyleOptionButton.
78
79 When reimplementing QStyle functions that take a QStyleOption
80 parameter, you often need to cast the QStyleOption to a subclass.
81 For safety, you can use qstyleoption_cast() to ensure that the
82 pointer type is correct. For example:
83
84 \snippet qstyleoption/main.cpp 4
85
86 The qstyleoption_cast() function will return 0 if the object to
87 which \c option points is not of the correct type.
88
89 For an example demonstrating how style options can be used, see
90 the \l {widgets/styles}{Styles} example.
91
92 \sa QStyle, QStylePainter
93*/
94
95/*!
96 \enum QStyleOption::OptionType
97
98 This enum is used internally by QStyleOption, its subclasses, and
99 qstyleoption_cast() to determine the type of style option. In
100 general you do not need to worry about this unless you want to
101 create your own QStyleOption subclass and your own styles.
102
103 \value SO_Button \l QStyleOptionButton
104 \value SO_ComboBox \l QStyleOptionComboBox
105 \value SO_Complex \l QStyleOptionComplex
106 \value SO_Default QStyleOption
107 \value SO_DockWidget \l QStyleOptionDockWidget
108 \value SO_FocusRect \l QStyleOptionFocusRect
109 \value SO_Frame \l QStyleOptionFrame
110 \value SO_GraphicsItem \l QStyleOptionGraphicsItem
111 \value SO_GroupBox \l QStyleOptionGroupBox
112 \value SO_Header \l QStyleOptionHeader
113 \value SO_MenuItem \l QStyleOptionMenuItem
114 \value SO_ProgressBar \l QStyleOptionProgressBar
115 \value SO_RubberBand \l QStyleOptionRubberBand
116 \value SO_SizeGrip \l QStyleOptionSizeGrip
117 \value SO_Slider \l QStyleOptionSlider
118 \value SO_SpinBox \l QStyleOptionSpinBox
119 \value SO_Tab \l QStyleOptionTab
120 \value SO_TabBarBase \l QStyleOptionTabBarBase
121 \value SO_TabWidgetFrame \l QStyleOptionTabWidgetFrame
122 \value SO_TitleBar \l QStyleOptionTitleBar
123 \value SO_ToolBar \l QStyleOptionToolBar
124 \value SO_ToolBox \l QStyleOptionToolBox
125 \value SO_ToolButton \l QStyleOptionToolButton
126 \value SO_ViewItem \l QStyleOptionViewItem (used in Interviews)
127
128 The following values are used for custom controls:
129
130 \value SO_CustomBase Reserved for custom QStyleOptions;
131 all custom controls values must be above this value
132 \value SO_ComplexCustomBase Reserved for custom QStyleOptions;
133 all custom complex controls values must be above this value
134
135 \sa type
136*/
137
138/*!
139 Constructs a QStyleOption with the specified \a version and \a
140 type.
141
142 The version has no special meaning for QStyleOption; it can be
143 used by subclasses to distinguish between different version of
144 the same option type.
145
146 The \l state member variable is initialized to
147 QStyle::State_None.
148
149 \sa version, type
150*/
151
152QStyleOption::QStyleOption(int version, int type)
153 : version(version), type(type), state(QStyle::State_None),
154 direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(nullptr)
155{
156}
157
158
159/*!
160 Destroys this style option object.
161*/
162QStyleOption::~QStyleOption()
163{
164}
165
166/*!
167 \fn void QStyleOption::initFrom(const QWidget *widget)
168 \since 4.1
169
170 Initializes the \l state, \l direction, \l rect, \l palette, \l fontMetrics
171 and \l styleObject member variables based on the specified \a widget.
172
173 This is a convenience function; the member variables can also be
174 initialized manually.
175
176 \sa QWidget::layoutDirection(), QWidget::rect(),
177 QWidget::palette(), QWidget::fontMetrics()
178*/
179void QStyleOption::initFrom(const QWidget *widget)
180{
181 QWidget *window = widget->window();
182 state = QStyle::State_None;
183 if (widget->isEnabled())
184 state |= QStyle::State_Enabled;
185 if (widget->hasFocus())
186 state |= QStyle::State_HasFocus;
187 if (window->testAttribute(Qt::WA_KeyboardFocusChange))
188 state |= QStyle::State_KeyboardFocusChange;
189 if (widget->underMouse())
190 state |= QStyle::State_MouseOver;
191 if (window->isActiveWindow())
192 state |= QStyle::State_Active;
193 if (widget->isWindow())
194 state |= QStyle::State_Window;
195 switch (QStyleHelper::widgetSizePolicy(widget)) {
196 case QStyleHelper::SizeSmall:
197 state |= QStyle::State_Small;
198 break;
199 case QStyleHelper::SizeMini:
200 state |= QStyle::State_Mini;
201 break;
202 default:
203 ;
204 }
205#ifdef QT_KEYPAD_NAVIGATION
206 if (widget->hasEditFocus())
207 state |= QStyle::State_HasEditFocus;
208#endif
209
210 direction = widget->layoutDirection();
211 rect = widget->rect();
212 palette = widget->palette();
213 fontMetrics = widget->fontMetrics();
214 styleObject = const_cast<QWidget*>(widget);
215}
216
217/*!
218 Constructs a copy of \a other.
219*/
220QStyleOption::QStyleOption(const QStyleOption &other)
221 : version(Version), type(Type), state(other.state),
222 direction(other.direction), rect(other.rect), fontMetrics(other.fontMetrics),
223 palette(other.palette), styleObject(other.styleObject)
224{
225}
226
227/*!
228 Assign \a other to this QStyleOption.
229*/
230QStyleOption &QStyleOption::operator=(const QStyleOption &other)
231{
232 state = other.state;
233 direction = other.direction;
234 rect = other.rect;
235 fontMetrics = other.fontMetrics;
236 palette = other.palette;
237 styleObject = other.styleObject;
238 return *this;
239}
240
241/*!
242 \enum QStyleOption::StyleOptionType
243
244 This enum is used to hold information about the type of the style option, and
245 is defined for each QStyleOption subclass.
246
247 \value Type The type of style option provided (\l{SO_Default} for
248 this class).
249
250 The type is used internally by QStyleOption, its subclasses, and
251 qstyleoption_cast() to determine the type of style option. In
252 general you do not need to worry about this unless you want to
253 create your own QStyleOption subclass and your own styles.
254
255 \sa StyleOptionVersion
256*/
257
258/*!
259 \enum QStyleOption::StyleOptionVersion
260
261 This enum is used to hold information about the version of the style option, and
262 is defined for each QStyleOption subclass.
263
264 \value Version 1
265
266 The version is used by QStyleOption subclasses to implement
267 extensions without breaking compatibility. If you use
268 qstyleoption_cast(), you normally do not need to check it.
269
270 \sa StyleOptionType
271*/
272
273/*!
274 \variable QStyleOption::palette
275 \brief the palette that should be used when painting the control
276
277 By default, the application's default palette is used.
278
279 \sa initFrom()
280*/
281
282/*!
283 \variable QStyleOption::direction
284 \brief the text layout direction that should be used when drawing text in the control
285
286 By default, the layout direction is Qt::LeftToRight.
287
288 \sa initFrom()
289*/
290
291/*!
292 \variable QStyleOption::fontMetrics
293 \brief the font metrics that should be used when drawing text in the control
294
295 By default, the application's default font is used.
296
297 \sa initFrom()
298*/
299
300/*!
301 \variable QStyleOption::styleObject
302 \brief the object being styled
303
304 The built-in styles support the following types: QWidget, QGraphicsObject and QQuickItem.
305
306 \sa initFrom()
307*/
308
309/*!
310 \variable QStyleOption::rect
311 \brief the area that should be used for various calculations and painting
312
313 This can have different meanings for different types of elements.
314 For example, for a \l QStyle::CE_PushButton element it would be
315 the rectangle for the entire button, while for a \l
316 QStyle::CE_PushButtonLabel element it would be just the area for
317 the push button label.
318
319 The default value is a null rectangle, i.e. a rectangle with both
320 the width and the height set to 0.
321
322 \sa initFrom()
323*/
324
325/*!
326 \variable QStyleOption::state
327 \brief the style flags that are used when drawing the control
328
329 The default value is QStyle::State_None.
330
331 \sa initFrom(), QStyle::drawPrimitive(), QStyle::drawControl(),
332 QStyle::drawComplexControl(), QStyle::State
333*/
334
335/*!
336 \variable QStyleOption::type
337 \brief the option type of the style option
338
339 The default value is SO_Default.
340
341 \sa OptionType
342*/
343
344/*!
345 \variable QStyleOption::version
346 \brief the version of the style option
347
348 This value can be used by subclasses to implement extensions
349 without breaking compatibility. If you use the qstyleoption_cast()
350 function, you normally do not need to check it.
351
352 The default value is 1.
353*/
354
355/*!
356 \class QStyleOptionFocusRect
357 \brief The QStyleOptionFocusRect class is used to describe the
358 parameters for drawing a focus rectangle with QStyle.
359
360 \inmodule QtWidgets
361
362 For performance reasons, there are few member functions and the
363 access to the member variables is direct (i.e., using the \c . or
364 \c -> operator). This makes the structures straightforward to use
365 and emphasizes that these are simply parameters used by the style
366 functions.
367
368 For an example demonstrating how style options can be used, see
369 the \l {widgets/styles}{Styles} example.
370
371 \sa QStyleOption
372*/
373
374/*!
375 Constructs a QStyleOptionFocusRect, initializing the members
376 variables to their default values.
377*/
378
379QStyleOptionFocusRect::QStyleOptionFocusRect()
380 : QStyleOption(Version, SO_FocusRect)
381{
382 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
383}
384
385/*!
386 \internal
387*/
388QStyleOptionFocusRect::QStyleOptionFocusRect(int version)
389 : QStyleOption(version, SO_FocusRect)
390{
391 state |= QStyle::State_KeyboardFocusChange; // assume we had one, will be corrected in initFrom()
392}
393
394/*!
395 \enum QStyleOptionFocusRect::StyleOptionType
396
397 This enum is used to hold information about the type of the style option, and
398 is defined for each QStyleOption subclass.
399
400 \value Type The type of style option provided (\l{SO_FocusRect} for this class).
401
402 The type is used internally by QStyleOption, its subclasses, and
403 qstyleoption_cast() to determine the type of style option. In
404 general you do not need to worry about this unless you want to
405 create your own QStyleOption subclass and your own styles.
406
407 \sa StyleOptionVersion
408*/
409
410/*!
411 \enum QStyleOptionFocusRect::StyleOptionVersion
412
413 This enum is used to hold information about the version of the style option, and
414 is defined for each QStyleOption subclass.
415
416 \value Version 1
417
418 The version is used by QStyleOption subclasses to implement
419 extensions without breaking compatibility. If you use
420 qstyleoption_cast(), you normally do not need to check it.
421
422 \sa StyleOptionType
423*/
424
425/*!
426 \fn QStyleOptionFocusRect::QStyleOptionFocusRect(const QStyleOptionFocusRect &other)
427
428 Constructs a copy of the \a other style option.
429*/
430
431/*!
432 \variable QStyleOptionFocusRect::backgroundColor
433 \brief the background color on which the focus rectangle is being drawn
434
435 The default value is an invalid color with the RGB value (0, 0,
436 0). An invalid color is a color that is not properly set up for
437 the underlying window system.
438*/
439
440/*!
441 \class QStyleOptionFrame
442 \brief The QStyleOptionFrame class is used to describe the
443 parameters for drawing a frame.
444
445 \inmodule QtWidgets
446
447 QStyleOptionFrame is used for drawing several built-in Qt widgets,
448 including QFrame, QGroupBox, QLineEdit, and QMenu.
449
450 For performance reasons, there are few member functions and the
451 access to the member variables is direct (i.e., using the \c . or
452 \c -> operator). This makes the structures straightforward to use
453 and emphasizes that these are simply parameters used by the style
454 functions.
455
456 An instance of the QStyleOptionFrame class has
457 \l{QStyleOption::type} {type} SO_Frame and \l{QStyleOption::version}
458 {version} 3.
459
460 The type is used internally by QStyleOption, its subclasses, and
461 qstyleoption_cast() to determine the type of style option. In
462 general you do not need to worry about this unless you want to
463 create your own QStyleOption subclass and your own styles. The
464 version is used by QStyleOption subclasses to implement extensions
465 without breaking compatibility. If you use qstyleoption_cast(),
466 you normally do not need to check it.
467
468 For an example demonstrating how style options can be used, see
469 the \l {widgets/styles}{Styles} example.
470
471 \sa QStyleOption
472*/
473
474/*!
475 Constructs a QStyleOptionFrame, initializing the members
476 variables to their default values.
477*/
478
479QStyleOptionFrame::QStyleOptionFrame()
480 : QStyleOption(Version, SO_Frame), lineWidth(0), midLineWidth(0),
481 features(None), frameShape(QFrame::NoFrame)
482{
483}
484
485/*!
486 \internal
487*/
488QStyleOptionFrame::QStyleOptionFrame(int version)
489 : QStyleOption(version, SO_Frame), lineWidth(0), midLineWidth(0),
490 features(None), frameShape(QFrame::NoFrame)
491{
492}
493
494/*!
495 \fn QStyleOptionFrame::QStyleOptionFrame(const QStyleOptionFrame &other)
496
497 Constructs a copy of the \a other style option.
498*/
499
500/*!
501 \enum QStyleOptionFrame::StyleOptionType
502
503 This enum is used to hold information about the type of the style option, and
504 is defined for each QStyleOption subclass.
505
506 \value Type The type of style option provided (\l{SO_Frame} for this class).
507
508 The type is used internally by QStyleOption, its subclasses, and
509 qstyleoption_cast() to determine the type of style option. In
510 general you do not need to worry about this unless you want to
511 create your own QStyleOption subclass and your own styles.
512
513 \sa StyleOptionVersion
514*/
515
516/*!
517 \enum QStyleOptionFrame::StyleOptionVersion
518
519 This enum is used to hold information about the version of the style option, and
520 is defined for each QStyleOption subclass.
521
522 \value Version 3
523
524 The version is used by QStyleOption subclasses to implement
525 extensions without breaking compatibility. If you use
526 qstyleoption_cast(), you normally do not need to check it.
527
528 \sa StyleOptionType
529*/
530
531/*!
532 \variable QStyleOptionFrame::lineWidth
533 \brief the line width for drawing the frame
534
535 The default value is 0.
536
537 \sa QFrame::lineWidth
538*/
539
540/*!
541 \variable QStyleOptionFrame::midLineWidth
542 \brief the mid-line width for drawing the frame
543
544 This is usually used in drawing sunken or raised frames.
545
546 The default value is 0.
547
548 \sa QFrame::midLineWidth
549*/
550
551/*!
552 \enum QStyleOptionFrame::FrameFeature
553
554 This enum describes the different types of features a frame can have.
555
556 \value None Indicates a normal frame.
557 \value Flat Indicates a flat frame.
558 \value Rounded Indicates a rounded frame.
559*/
560
561/*!
562 \variable QStyleOptionFrame::features
563 \brief a bitwise OR of the features that describe this frame.
564
565 \sa FrameFeature
566*/
567
568/*!
569 \variable QStyleOptionFrame::frameShape
570 \brief This property holds the frame shape value of the frame.
571
572 \sa QFrame::frameShape
573*/
574
575/*!
576 \class QStyleOptionGroupBox
577 \brief The QStyleOptionGroupBox class describes the parameters for
578 drawing a group box.
579
580 \since 4.1
581 \inmodule QtWidgets
582
583 QStyleOptionButton contains all the information that QStyle
584 functions need the various graphical elements of a group box.
585
586 It holds the lineWidth and the midLineWidth for drawing the panel,
587 the group box's \l {text}{title} and the title's \l
588 {textAlignment}{alignment} and \l {textColor}{color}.
589
590 For performance reasons, there are few member functions and the
591 access to the member variables is direct (i.e., using the \c . or
592 \c -> operator). This makes the structures straightforward to use
593 and emphasizes that these are simply parameters used by the style
594 functions.
595
596 For an example demonstrating how style options can be used, see
597 the \l {widgets/styles}{Styles} example.
598
599 \sa QStyleOption, QStyleOptionComplex, QGroupBox
600*/
601
602/*!
603 \enum QStyleOptionGroupBox::StyleOptionType
604
605 This enum is used to hold information about the type of the style option, and
606 is defined for each QStyleOption subclass.
607
608 \value Type The type of style option provided (\l{SO_GroupBox} for this class).
609
610 The type is used internally by QStyleOption, its subclasses, and
611 qstyleoption_cast() to determine the type of style option. In
612 general you do not need to worry about this unless you want to
613 create your own QStyleOption subclass and your own styles.
614
615 \sa StyleOptionVersion
616*/
617
618/*!
619 \enum QStyleOptionGroupBox::StyleOptionVersion
620
621 This enum is used to hold information about the version of the style option, and
622 is defined for each QStyleOption subclass.
623
624 \value Version 1
625
626 The version is used by QStyleOption subclasses to implement
627 extensions without breaking compatibility. If you use
628 qstyleoption_cast(), you normally do not need to check it.
629
630 \sa StyleOptionType
631*/
632
633/*!
634 \variable QStyleOptionGroupBox::lineWidth
635 \brief the line width for drawing the panel
636
637 The value of this variable is, currently, always 1.
638
639 \sa QFrame::lineWidth
640*/
641
642/*!
643 \variable QStyleOptionGroupBox::midLineWidth
644 \brief the mid-line width for drawing the panel
645
646 The mid-line width is usually used when drawing sunken or raised
647 group box frames. The value of this variable is, currently, always 0.
648
649 \sa QFrame::midLineWidth
650*/
651
652/*!
653 \variable QStyleOptionGroupBox::text
654 \brief the text of the group box
655
656 The default value is an empty string.
657
658 \sa QGroupBox::title
659*/
660
661/*!
662 \variable QStyleOptionGroupBox::textAlignment
663 \brief the alignment of the group box title
664
665 The default value is Qt::AlignLeft.
666
667 \sa QGroupBox::alignment
668*/
669
670/*!
671 \variable QStyleOptionGroupBox::features
672 \brief the features of the group box frame
673
674 The frame is flat by default.
675
676 \sa QStyleOptionFrame::FrameFeature
677*/
678
679/*!
680 \variable QStyleOptionGroupBox::textColor
681 \brief the color of the group box title
682
683 The default value is an invalid color with the RGB value (0, 0,
684 0). An invalid color is a color that is not properly set up for
685 the underlying window system.
686*/
687
688/*!
689 Constructs a QStyleOptionGroupBox, initializing the members
690 variables to their default values.
691*/
692QStyleOptionGroupBox::QStyleOptionGroupBox()
693 : QStyleOptionComplex(Version, Type), features(QStyleOptionFrame::None),
694 textAlignment(Qt::AlignLeft), lineWidth(0), midLineWidth(0)
695{
696}
697
698/*!
699 \fn QStyleOptionGroupBox::QStyleOptionGroupBox(const QStyleOptionGroupBox &other)
700
701 Constructs a copy of the \a other style option.
702*/
703
704/*!
705 \internal
706*/
707QStyleOptionGroupBox::QStyleOptionGroupBox(int version)
708 : QStyleOptionComplex(version, Type), features(QStyleOptionFrame::None),
709 textAlignment(Qt::AlignLeft), lineWidth(0), midLineWidth(0)
710{
711}
712
713/*!
714 \class QStyleOptionHeader
715 \brief The QStyleOptionHeader class is used to describe the
716 parameters for drawing a header.
717
718 \inmodule QtWidgets
719
720 QStyleOptionHeader contains all the information that QStyle
721 functions need to draw the item views' header pane, header sort
722 arrow, and header label.
723
724 For performance reasons, there are few member functions and the
725 access to the member variables is direct (i.e., using the \c . or
726 \c -> operator). This makes the structures straightforward to use
727 and emphasizes that these are simply parameters used by the style
728 functions.
729
730 For an example demonstrating how style options can be used, see
731 the \l {widgets/styles}{Styles} example.
732
733 \sa QStyleOption
734*/
735
736/*!
737 Constructs a QStyleOptionHeader, initializing the members
738 variables to their default values.
739*/
740
741QStyleOptionHeader::QStyleOptionHeader()
742 : QStyleOption(QStyleOptionHeader::Version, SO_Header),
743 section(0), textAlignment(Qt::AlignLeft), iconAlignment(Qt::AlignLeft),
744 position(QStyleOptionHeader::Beginning),
745 selectedPosition(QStyleOptionHeader::NotAdjacent), sortIndicator(None),
746 orientation(Qt::Horizontal)
747{
748}
749
750/*!
751 \internal
752*/
753QStyleOptionHeader::QStyleOptionHeader(int version)
754 : QStyleOption(version, SO_Header),
755 section(0), textAlignment(Qt::AlignLeft), iconAlignment(Qt::AlignLeft),
756 position(QStyleOptionHeader::Beginning),
757 selectedPosition(QStyleOptionHeader::NotAdjacent), sortIndicator(None),
758 orientation(Qt::Horizontal)
759{
760}
761
762/*!
763 \variable QStyleOptionHeader::orientation
764 \brief the header's orientation (horizontal or vertical)
765
766 The default orientation is Qt::Horizontal
767*/
768
769/*!
770 \fn QStyleOptionHeader::QStyleOptionHeader(const QStyleOptionHeader &other)
771
772 Constructs a copy of the \a other style option.
773*/
774
775/*!
776 \enum QStyleOptionHeader::StyleOptionType
777
778 This enum is used to hold information about the type of the style option, and
779 is defined for each QStyleOption subclass.
780
781 \value Type The type of style option provided (\l{SO_Header} for this class).
782
783 The type is used internally by QStyleOption, its subclasses, and
784 qstyleoption_cast() to determine the type of style option. In
785 general you do not need to worry about this unless you want to
786 create your own QStyleOption subclass and your own styles.
787
788 \sa StyleOptionVersion
789*/
790
791/*!
792 \enum QStyleOptionHeader::StyleOptionVersion
793
794 This enum is used to hold information about the version of the style option, and
795 is defined for each QStyleOption subclass.
796
797 \value Version 1
798
799 The version is used by QStyleOption subclasses to implement
800 extensions without breaking compatibility. If you use
801 qstyleoption_cast(), you normally do not need to check it.
802
803 \sa StyleOptionType
804*/
805
806/*!
807 \variable QStyleOptionHeader::section
808 \brief which section of the header is being painted
809
810 The default value is 0.
811*/
812
813/*!
814 \variable QStyleOptionHeader::text
815 \brief the text of the header
816
817 The default value is an empty string.
818*/
819
820/*!
821 \variable QStyleOptionHeader::textAlignment
822 \brief the alignment flags for the text of the header
823
824 The default value is Qt::AlignLeft.
825*/
826
827/*!
828 \variable QStyleOptionHeader::icon
829 \brief the icon of the header
830
831 The default value is an empty icon, i.e. an icon with neither a
832 pixmap nor a filename.
833*/
834
835/*!
836 \variable QStyleOptionHeader::iconAlignment
837 \brief the alignment flags for the icon of the header
838
839 The default value is Qt::AlignLeft.
840*/
841
842/*!
843 \variable QStyleOptionHeader::position
844 \brief the section's position in relation to the other sections
845
846 The default value is QStyleOptionHeader::Beginning.
847*/
848
849/*!
850 \variable QStyleOptionHeader::selectedPosition
851 \brief the section's position in relation to the selected section
852
853 The default value is QStyleOptionHeader::NotAdjacent
854*/
855
856/*!
857 \variable QStyleOptionHeader::sortIndicator
858 \brief the direction the sort indicator should be drawn
859
860 The default value is QStyleOptionHeader::None.
861*/
862
863/*!
864 \enum QStyleOptionHeader::SectionPosition
865
866 This enum lets you know where the section's position is in relation to the other sections.
867
868 \value Beginning At the beginining of the header
869 \value Middle In the middle of the header
870 \value End At the end of the header
871 \value OnlyOneSection Only one header section
872
873 \sa position
874*/
875
876/*!
877 \enum QStyleOptionHeader::SelectedPosition
878
879 This enum lets you know where the section's position is in relation to the selected section.
880
881 \value NotAdjacent Not adjacent to the selected section
882 \value NextIsSelected The next section is selected
883 \value PreviousIsSelected The previous section is selected
884 \value NextAndPreviousAreSelected Both the next and previous section are selected
885
886 \sa selectedPosition
887*/
888
889/*!
890 \enum QStyleOptionHeader::SortIndicator
891
892 Indicates which direction the sort indicator should be drawn
893
894 \value None No sort indicator is needed
895 \value SortUp Draw an up indicator
896 \value SortDown Draw a down indicator
897
898 \sa sortIndicator
899*/
900
901/*!
902 \class QStyleOptionButton
903 \brief The QStyleOptionButton class is used to describe the
904 parameters for drawing buttons.
905
906 \inmodule QtWidgets
907
908 QStyleOptionButton contains all the information that QStyle
909 functions need to draw graphical elements like QPushButton,
910 QCheckBox, and QRadioButton.
911
912 For performance reasons, there are few member functions and the
913 access to the member variables is direct (i.e., using the \c . or
914 \c -> operator). This makes the structures straightforward to use
915 and emphasizes that these are simply parameters used by the style
916 functions.
917
918 For an example demonstrating how style options can be used, see
919 the \l {widgets/styles}{Styles} example.
920
921 \sa QStyleOption, QStyleOptionToolButton
922*/
923
924/*!
925 \enum QStyleOptionButton::ButtonFeature
926
927 This enum describes the different types of features a push button can have.
928
929 \value None Indicates a normal push button.
930 \value Flat Indicates a flat push button.
931 \value HasMenu Indicates that the button has a drop down menu.
932 \value DefaultButton Indicates that the button is a default button.
933 \value AutoDefaultButton Indicates that the button is an auto default button.
934 \value CommandLinkButton Indicates that the button is a Windows Vista type command link.
935
936 \sa features
937*/
938
939/*!
940 Constructs a QStyleOptionButton, initializing the members
941 variables to their default values.
942*/
943
944QStyleOptionButton::QStyleOptionButton()
945 : QStyleOption(QStyleOptionButton::Version, SO_Button), features(None)
946{
947}
948
949/*!
950 \internal
951*/
952QStyleOptionButton::QStyleOptionButton(int version)
953 : QStyleOption(version, SO_Button), features(None)
954{
955}
956
957/*!
958 \fn QStyleOptionButton::QStyleOptionButton(const QStyleOptionButton &other)
959
960 Constructs a copy of the \a other style option.
961*/
962
963/*!
964 \enum QStyleOptionButton::StyleOptionType
965
966 This enum is used to hold information about the type of the style option, and
967 is defined for each QStyleOption subclass.
968
969 \value Type The type of style option provided (\l{SO_Button} for this class).
970
971 The type is used internally by QStyleOption, its subclasses, and
972 qstyleoption_cast() to determine the type of style option. In
973 general you do not need to worry about this unless you want to
974 create your own QStyleOption subclass and your own styles.
975
976 \sa StyleOptionVersion
977*/
978
979/*!
980 \enum QStyleOptionButton::StyleOptionVersion
981
982 This enum is used to hold information about the version of the style option, and
983 is defined for each QStyleOption subclass.
984
985 \value Version 1
986
987 The version is used by QStyleOption subclasses to implement
988 extensions without breaking compatibility. If you use
989 qstyleoption_cast(), you normally do not need to check it.
990
991 \sa StyleOptionType
992*/
993
994/*!
995 \variable QStyleOptionButton::features
996 \brief a bitwise OR of the features that describe this button
997
998 \sa ButtonFeature
999*/
1000
1001/*!
1002 \variable QStyleOptionButton::text
1003 \brief the text of the button
1004
1005 The default value is an empty string.
1006*/
1007
1008/*!
1009 \variable QStyleOptionButton::icon
1010 \brief the icon of the button
1011
1012 The default value is an empty icon, i.e. an icon with neither a
1013 pixmap nor a filename.
1014
1015 \sa iconSize
1016*/
1017
1018/*!
1019 \variable QStyleOptionButton::iconSize
1020 \brief the size of the icon for the button
1021
1022 The default value is QSize(-1, -1), i.e. an invalid size.
1023*/
1024
1025
1026#if QT_CONFIG(toolbar)
1027/*!
1028 \class QStyleOptionToolBar
1029 \brief The QStyleOptionToolBar class is used to describe the
1030 parameters for drawing a toolbar.
1031
1032 \since 4.1
1033 \inmodule QtWidgets
1034
1035 QStyleOptionToolBar contains all the information that QStyle
1036 functions need to draw QToolBar.
1037
1038 The QStyleOptionToolBar class holds the lineWidth and the
1039 midLineWidth for drawing the widget. It also stores information
1040 about which \l {toolBarArea}{area} the toolbar should be located
1041 in, whether it is movable or not, which position the toolbar line
1042 should have (positionOfLine), and the toolbar's position within
1043 the line (positionWithinLine).
1044
1045 In addition, the class provides a couple of enums: The
1046 ToolBarFeature enum is used to describe whether a toolbar is
1047 movable or not, and the ToolBarPosition enum is used to describe
1048 the position of a toolbar line, as well as the toolbar's position
1049 within the line.
1050
1051 For performance reasons, there are few member functions and the
1052 access to the member variables is direct (i.e., using the \c . or
1053 \c -> operator). This makes the structures straightforward to use
1054 and emphasizes that these are simply parameters used by the style
1055 functions.
1056
1057 For an example demonstrating how style options can be used, see
1058 the \l {widgets/styles}{Styles} example.
1059
1060 \sa QStyleOption
1061*/
1062
1063/*!
1064 Constructs a QStyleOptionToolBar, initializing the members
1065 variables to their default values.
1066*/
1067
1068QStyleOptionToolBar::QStyleOptionToolBar()
1069 : QStyleOption(Version, SO_ToolBar), positionOfLine(OnlyOne), positionWithinLine(OnlyOne),
1070 toolBarArea(Qt::TopToolBarArea), features(None), lineWidth(0), midLineWidth(0)
1071{
1072}
1073
1074/*!
1075 \fn QStyleOptionToolBar::QStyleOptionToolBar(const QStyleOptionToolBar &other)
1076
1077 Constructs a copy of the \a other style option.
1078*/
1079
1080/*!
1081 \internal
1082*/
1083QStyleOptionToolBar::QStyleOptionToolBar(int version)
1084: QStyleOption(version, SO_ToolBar), positionOfLine(OnlyOne), positionWithinLine(OnlyOne),
1085 toolBarArea(Qt::TopToolBarArea), features(None), lineWidth(0), midLineWidth(0)
1086{
1087
1088}
1089
1090/*!
1091 \enum QStyleOptionToolBar::ToolBarPosition
1092
1093 \image qstyleoptiontoolbar-position.png
1094
1095 This enum is used to describe the position of a toolbar line, as
1096 well as the toolbar's position within the line.
1097
1098 The order of the positions within a line starts at the top of a
1099 vertical line, and from the left within a horizontal line. The
1100 order of the positions for the lines is always from the
1101 parent widget's boundary edges.
1102
1103 \value Beginning The toolbar is located at the beginning of the line,
1104 or the toolbar line is the first of several lines. There can
1105 only be one toolbar (and only one line) with this position.
1106 \value Middle The toolbar is located in the middle of the line,
1107 or the toolbar line is in the middle of several lines. There can
1108 several toolbars (and lines) with this position.
1109 \value End The toolbar is located at the end of the line,
1110 or the toolbar line is the last of several lines. There can
1111 only be one toolbar (and only one line) with this position.
1112 \value OnlyOne There is only one toolbar or line. This is the default value
1113 of the positionOfLine and positionWithinLine variables.
1114
1115 \sa positionWithinLine, positionOfLine
1116*/
1117
1118/*!
1119 \enum QStyleOptionToolBar::ToolBarFeature
1120
1121 This enum is used to describe whether a toolbar is movable or not.
1122
1123 \value None The toolbar cannot be moved. The default value.
1124 \value Movable The toolbar is movable, and a handle will appear when
1125 holding the cursor over the toolbar's boundary.
1126
1127 \sa features, QToolBar::isMovable()
1128*/
1129
1130/*!
1131 \variable QStyleOptionToolBar::positionOfLine
1132
1133 This variable holds the position of the toolbar line.
1134
1135 The default value is QStyleOptionToolBar::OnlyOne.
1136*/
1137
1138/*!
1139 \variable QStyleOptionToolBar::positionWithinLine
1140
1141 This variable holds the position of the toolbar within a line.
1142
1143 The default value is QStyleOptionToolBar::OnlyOne.
1144*/
1145
1146/*!
1147 \variable QStyleOptionToolBar::toolBarArea
1148
1149 This variable holds the location for drawing the toolbar.
1150
1151 The default value is Qt::TopToolBarArea.
1152
1153 \sa Qt::ToolBarArea
1154*/
1155
1156/*!
1157 \variable QStyleOptionToolBar::features
1158
1159 This variable holds whether the toolbar is movable or not.
1160
1161 The default value is \l None.
1162*/
1163
1164/*!
1165 \variable QStyleOptionToolBar::lineWidth
1166
1167 This variable holds the line width for drawing the toolbar.
1168
1169 The default value is 0.
1170*/
1171
1172/*!
1173 \variable QStyleOptionToolBar::midLineWidth
1174
1175 This variable holds the mid-line width for drawing the toolbar.
1176
1177 The default value is 0.
1178*/
1179
1180/*!
1181 \enum QStyleOptionToolBar::StyleOptionType
1182
1183 This enum is used to hold information about the type of the style
1184 option, and is defined for each QStyleOption subclass.
1185
1186 \value Type The type of style option provided (\l{SO_ToolBar} for
1187 this class).
1188
1189 The type is used internally by QStyleOption, its subclasses, and
1190 qstyleoption_cast() to determine the type of style option. In
1191 general you do not need to worry about this unless you want to
1192 create your own QStyleOption subclass and your own styles.
1193
1194 \sa StyleOptionVersion
1195*/
1196
1197/*!
1198 \enum QStyleOptionToolBar::StyleOptionVersion
1199
1200 This enum is used to hold information about the version of the
1201 style option, and is defined for each QStyleOption subclass.
1202
1203 \value Version 1
1204
1205 The version is used by QStyleOption subclasses to implement
1206 extensions without breaking compatibility. If you use
1207 qstyleoption_cast(), you normally do not need to check it.
1208
1209 \sa StyleOptionType
1210*/
1211
1212#endif
1213
1214#if QT_CONFIG(tabbar)
1215/*!
1216 \class QStyleOptionTab
1217 \brief The QStyleOptionTab class is used to describe the
1218 parameters for drawing a tab bar.
1219
1220 \inmodule QtWidgets
1221
1222 The QStyleOptionTab class is used for drawing several built-in Qt
1223 widgets including \l QTabBar and the panel for \l QTabWidget.
1224
1225 An instance of the QStyleOptionTab class has
1226 \l{QStyleOption::type} {type} \l SO_Tab and
1227 \l{QStyleOption::version} {version} 3. The type is used internally
1228 by QStyleOption, its subclasses, and qstyleoption_cast() to
1229 determine the type of style option. In general you do not need to
1230 worry about this unless you want to create your own QStyleOption
1231 subclass and your own styles. The version is used by QStyleOption
1232 subclasses to implement extensions without breaking
1233 compatibility. If you use qstyleoption_cast(), you normally do not
1234 need to check it.
1235
1236 For performance reasons, there are few member functions and the
1237 access to the member variables is direct (i.e., using the \c . or
1238 \c -> operator). This makes the structures straightforward to use
1239 and emphasizes that these are simply parameters used by the style
1240 functions.
1241
1242 For an example demonstrating how style options can be used, see
1243 the \l {widgets/styles}{Styles} example.
1244
1245 \sa QStyleOption
1246*/
1247
1248/*!
1249 Constructs a QStyleOptionTab object, initializing the members
1250 variables to their default values.
1251*/
1252
1253QStyleOptionTab::QStyleOptionTab()
1254 : QStyleOption(QStyleOptionTab::Version, SO_Tab),
1255 shape(QTabBar::RoundedNorth),
1256 row(0),
1257 position(Beginning),
1258 selectedPosition(NotAdjacent), cornerWidgets(QStyleOptionTab::NoCornerWidgets),
1259 documentMode(false),
1260 features(QStyleOptionTab::None)
1261{
1262}
1263
1264/*!
1265 \internal
1266*/
1267QStyleOptionTab::QStyleOptionTab(int version)
1268 : QStyleOption(version, SO_Tab),
1269 shape(QTabBar::RoundedNorth),
1270 row(0),
1271 position(Beginning),
1272 selectedPosition(NotAdjacent), cornerWidgets(QStyleOptionTab::NoCornerWidgets),
1273 documentMode(false),
1274 features(QStyleOptionTab::None)
1275{
1276}
1277
1278/*!
1279 \fn QStyleOptionTab::QStyleOptionTab(const QStyleOptionTab &other)
1280
1281 Constructs a copy of the \a other style option.
1282*/
1283
1284/*!
1285 \enum QStyleOptionTab::StyleOptionType
1286
1287 This enum is used to hold information about the type of the style option, and
1288 is defined for each QStyleOption subclass.
1289
1290 \value Type The type of style option provided (\l{SO_Tab} for this class).
1291
1292 The type is used internally by QStyleOption, its subclasses, and
1293 qstyleoption_cast() to determine the type of style option. In
1294 general you do not need to worry about this unless you want to
1295 create your own QStyleOption subclass and your own styles.
1296
1297 \sa StyleOptionVersion
1298*/
1299
1300/*!
1301 \enum QStyleOptionTab::StyleOptionVersion
1302
1303 This enum is used to hold information about the version of the style option, and
1304 is defined for each QStyleOption subclass.
1305
1306 \value Version 3
1307
1308 The version is used by QStyleOption subclasses to implement
1309 extensions without breaking compatibility. If you use
1310 qstyleoption_cast(), you normally do not need to check it.
1311
1312 \sa StyleOptionType
1313*/
1314
1315/*!
1316 \enum QStyleOptionTab::TabPosition
1317
1318 This enum describes the position of the tab.
1319
1320 \value Beginning The tab is the first tab in the tab bar.
1321 \value Middle The tab is neither the first nor the last tab in the tab bar.
1322 \value End The tab is the last tab in the tab bar.
1323 \value OnlyOneTab The tab is both the first and the last tab in the tab bar.
1324
1325 \sa position
1326*/
1327
1328/*!
1329 \enum QStyleOptionTab::CornerWidget
1330
1331 These flags indicate the corner widgets in a tab.
1332
1333 \value NoCornerWidgets There are no corner widgets
1334 \value LeftCornerWidget Left corner widget
1335 \value RightCornerWidget Right corner widget
1336
1337 \sa cornerWidgets
1338*/
1339
1340/*! \enum QStyleOptionTab::SelectedPosition
1341
1342 This enum describes the position of the selected tab. Some styles
1343 need to draw a tab differently depending on whether or not it is
1344 adjacent to the selected tab.
1345
1346 \value NotAdjacent The tab is not adjacent to a selected tab (or is the selected tab).
1347 \value NextIsSelected The next tab (typically the tab on the right) is selected.
1348 \value PreviousIsSelected The previous tab (typically the tab on the left) is selected.
1349
1350 \sa selectedPosition
1351*/
1352
1353/*!
1354 \variable QStyleOptionTab::selectedPosition
1355 \brief the position of the selected tab in relation to this tab
1356
1357 The default value is NotAdjacent, i.e. the tab is not adjacent to
1358 a selected tab nor is it the selected tab.
1359*/
1360
1361/*!
1362 \variable QStyleOptionTab::cornerWidgets
1363 \brief an OR combination of CornerWidget values indicating the
1364 corner widgets of the tab bar
1365
1366 The default value is NoCornerWidgets.
1367
1368 \sa CornerWidget
1369*/
1370
1371
1372/*!
1373 \variable QStyleOptionTab::shape
1374 \brief the tab shape used to draw the tab; by default
1375 QTabBar::RoundedNorth
1376
1377 \sa QTabBar::Shape
1378*/
1379
1380/*!
1381 \variable QStyleOptionTab::text
1382 \brief the text of the tab
1383
1384 The default value is an empty string.
1385*/
1386
1387/*!
1388 \variable QStyleOptionTab::icon
1389 \brief the icon for the tab
1390
1391 The default value is an empty icon, i.e. an icon with neither a
1392 pixmap nor a filename.
1393*/
1394
1395/*!
1396 \variable QStyleOptionTab::row
1397 \brief which row the tab is currently in
1398
1399 The default value is 0, indicating the front row. Currently this
1400 property can only be 0.
1401*/
1402
1403/*!
1404 \variable QStyleOptionTab::position
1405 \brief the position of the tab in the tab bar
1406
1407 The default value is \l Beginning, i.e. the tab is the first tab
1408 in the tab bar.
1409*/
1410/*!
1411 \variable QStyleOptionTab::iconSize
1412 \brief the size for the icons
1413
1414 The default value is QSize(-1, -1), i.e. an invalid size; use
1415 QStyle::pixelMetric() to find the default icon size for tab bars.
1416
1417 \sa QTabBar::iconSize()
1418*/
1419
1420/*!
1421 \variable QStyleOptionTab::documentMode
1422 \brief whether the tabbar is in document mode.
1423
1424 The default value is false;
1425*/
1426
1427/*!
1428 \enum QStyleOptionTab::TabFeature
1429
1430 Describes the various features that a tab button can have.
1431
1432 \value None A normal tab button.
1433 \value HasFrame The tab button is positioned on a tab frame
1434
1435 \sa QStyleOptionToolBar::features
1436*/
1437
1438/*!
1439 \variable QStyleOptionTab::leftButtonSize
1440 \brief the size for the left widget on the tab.
1441
1442 The default value is QSize(-1, -1), i.e. an invalid size;
1443*/
1444
1445/*!
1446 \variable QStyleOptionTab::rightButtonSize
1447 \brief the size for the right widget on the tab.
1448
1449 The default value is QSize(-1, -1), i.e. an invalid size;
1450*/
1451
1452/*!
1453 \variable QStyleOptionTab::tabIndex
1454 \brief the index for the tab being represented.
1455
1456 The default value is -1, i.e. a tab not on a tabbar;
1457 */
1458
1459#endif // QT_CONFIG(tabbar)
1460
1461/*!
1462 \class QStyleOptionProgressBar
1463 \brief The QStyleOptionProgressBar class is used to describe the
1464 parameters necessary for drawing a progress bar.
1465
1466 \inmodule QtWidgets
1467
1468 An instance of the QStyleOptionProgressBar class has type
1469 SO_ProgressBar and version 2.
1470
1471 The type is used internally by QStyleOption, its subclasses, and
1472 qstyleoption_cast() to determine the type of style option. In
1473 general you do not need to worry about this unless you want to
1474 create your own QStyleOption subclass and your own styles. The
1475 version is used by QStyleOption subclasses to implement extensions
1476 without breaking compatibility. If you use qstyleoption_cast(),
1477 you normally do not need to check it.
1478
1479 For performance reasons, there are few member functions and the
1480 access to the member variables is direct (i.e., using the \c . or
1481 \c -> operator). This makes the structures straightforward to use
1482 and emphasizes that these are simply parameters used by the style
1483 functions.
1484
1485 For an example demonstrating how style options can be used, see
1486 the \l {widgets/styles}{Styles} example.
1487
1488 \sa QStyleOption
1489*/
1490
1491/*!
1492 Constructs a QStyleOptionProgressBar, initializing the members
1493 variables to their default values.
1494*/
1495
1496QStyleOptionProgressBar::QStyleOptionProgressBar()
1497 : QStyleOption(QStyleOptionProgressBar::Version, SO_ProgressBar),
1498 minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false),
1499 invertedAppearance(false), bottomToTop(false)
1500{
1501}
1502
1503/*!
1504 \internal
1505*/
1506QStyleOptionProgressBar::QStyleOptionProgressBar(int version)
1507 : QStyleOption(version, SO_ProgressBar),
1508 minimum(0), maximum(0), progress(0), textAlignment(Qt::AlignLeft), textVisible(false),
1509 invertedAppearance(false), bottomToTop(false)
1510{
1511}
1512
1513/*!
1514 \fn QStyleOptionProgressBar::QStyleOptionProgressBar(const QStyleOptionProgressBar &other)
1515
1516 Constructs a copy of the \a other style option.
1517*/
1518
1519/*!
1520 \enum QStyleOptionProgressBar::StyleOptionType
1521
1522 This enum is used to hold information about the type of the style option, and
1523 is defined for each QStyleOption subclass.
1524
1525 \value Type The type of style option provided (\l{SO_ProgressBar} for this class).
1526
1527 The type is used internally by QStyleOption, its subclasses, and
1528 qstyleoption_cast() to determine the type of style option. In
1529 general you do not need to worry about this unless you want to
1530 create your own QStyleOption subclass and your own styles.
1531
1532 \sa StyleOptionVersion
1533*/
1534
1535/*!
1536 \enum QStyleOptionProgressBar::StyleOptionVersion
1537
1538 This enum is used to hold information about the version of the style option, and
1539 is defined for each QStyleOption subclass.
1540
1541 \value Version 2
1542
1543 The version is used by QStyleOption subclasses to implement
1544 extensions without breaking compatibility. If you use
1545 qstyleoption_cast(), you normally do not need to check it.
1546
1547 \sa StyleOptionType
1548*/
1549
1550/*!
1551 \variable QStyleOptionProgressBar::minimum
1552 \brief the minimum value for the progress bar
1553
1554 This is the minimum value in the progress bar. The default value
1555 is 0.
1556
1557 \sa QProgressBar::minimum
1558*/
1559
1560/*!
1561 \variable QStyleOptionProgressBar::maximum
1562 \brief the maximum value for the progress bar
1563
1564 This is the maximum value in the progress bar. The default value
1565 is 0.
1566
1567 \sa QProgressBar::maximum
1568*/
1569
1570/*!
1571 \variable QStyleOptionProgressBar::text
1572 \brief the text for the progress bar
1573
1574 The progress bar text is usually just the progress expressed as a
1575 string. An empty string indicates that the progress bar has not
1576 started yet. The default value is an empty string.
1577
1578 \sa QProgressBar::text
1579*/
1580
1581/*!
1582 \variable QStyleOptionProgressBar::textVisible
1583 \brief a flag indicating whether or not text is visible
1584
1585 If this flag is true then the text is visible. Otherwise, the text
1586 is not visible. The default value is false.
1587
1588 \sa QProgressBar::textVisible
1589*/
1590
1591
1592/*!
1593 \variable QStyleOptionProgressBar::textAlignment
1594 \brief the text alignment for the text in the QProgressBar
1595
1596 This can be used as a guide on where the text should be in the
1597 progress bar. The default value is Qt::AlignLeft.
1598*/
1599
1600/*!
1601 \variable QStyleOptionProgressBar::progress
1602 \brief the current progress for the progress bar
1603
1604 The current progress. A value of QStyleOptionProgressBar::minimum
1605 - 1 indicates that the progress hasn't started yet. The default
1606 value is 0.
1607
1608 \sa QProgressBar::value
1609*/
1610
1611/*!
1612 \variable QStyleOptionProgressBar::invertedAppearance
1613 \brief whether the progress bar's appearance is inverted
1614
1615 The default value is false.
1616
1617 \sa QProgressBar::invertedAppearance
1618*/
1619
1620/*!
1621 \variable QStyleOptionProgressBar::bottomToTop
1622 \brief whether the text reads from bottom to top when the progress
1623 bar is vertical
1624
1625 The default value is false.
1626
1627 \sa QProgressBar::textDirection
1628*/
1629
1630/*!
1631 \class QStyleOptionMenuItem
1632 \brief The QStyleOptionMenuItem class is used to describe the
1633 parameter necessary for drawing a menu item.
1634
1635 \inmodule QtWidgets
1636
1637 QStyleOptionMenuItem contains all the information that QStyle
1638 functions need to draw the menu items from \l QMenu. It is also
1639 used for drawing other menu-related widgets.
1640
1641 For performance reasons, there are few member functions and the
1642 access to the member variables is direct (i.e., using the \c . or
1643 \c -> operator). This makes the structures straightforward to use
1644 and emphasizes that these are simply parameters used by the style
1645 functions.
1646
1647 For an example demonstrating how style options can be used, see
1648 the \l {widgets/styles}{Styles} example.
1649
1650 \sa QStyleOption
1651*/
1652
1653/*!
1654 Constructs a QStyleOptionMenuItem, initializing the members
1655 variables to their default values.
1656*/
1657
1658QStyleOptionMenuItem::QStyleOptionMenuItem()
1659 : QStyleOption(QStyleOptionMenuItem::Version, SO_MenuItem), menuItemType(Normal),
1660 checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0),
1661 reservedShortcutWidth(0)
1662{
1663}
1664
1665/*!
1666 \internal
1667*/
1668QStyleOptionMenuItem::QStyleOptionMenuItem(int version)
1669 : QStyleOption(version, SO_MenuItem), menuItemType(Normal),
1670 checkType(NotCheckable), checked(false), menuHasCheckableItems(true), maxIconWidth(0),
1671 reservedShortcutWidth(0)
1672{
1673}
1674
1675/*!
1676 \fn QStyleOptionMenuItem::QStyleOptionMenuItem(const QStyleOptionMenuItem &other)
1677
1678 Constructs a copy of the \a other style option.
1679*/
1680
1681/*!
1682 \enum QStyleOptionMenuItem::StyleOptionType
1683
1684 This enum is used to hold information about the type of the style option, and
1685 is defined for each QStyleOption subclass.
1686
1687 \value Type The type of style option provided (\l{SO_MenuItem} for this class).
1688
1689 The type is used internally by QStyleOption, its subclasses, and
1690 qstyleoption_cast() to determine the type of style option. In
1691 general you do not need to worry about this unless you want to
1692 create your own QStyleOption subclass and your own styles.
1693
1694 \sa StyleOptionVersion
1695*/
1696
1697/*!
1698 \enum QStyleOptionMenuItem::StyleOptionVersion
1699
1700 This enum is used to hold information about the version of the style option, and
1701 is defined for each QStyleOption subclass.
1702
1703 \value Version 1
1704
1705 The version is used by QStyleOption subclasses to implement
1706 extensions without breaking compatibility. If you use
1707 qstyleoption_cast(), you normally do not need to check it.
1708
1709 \sa StyleOptionType
1710*/
1711
1712/*!
1713 \enum QStyleOptionMenuItem::MenuItemType
1714
1715 This enum indicates the type of menu item that the structure describes.
1716
1717 \value Normal A normal menu item.
1718 \value DefaultItem A menu item that is the default action as specified with \l QMenu::defaultAction().
1719 \value Separator A menu separator.
1720 \value SubMenu Indicates the menu item points to a sub-menu.
1721 \value Scroller A popup menu scroller (currently only used on \macos).
1722 \value TearOff A tear-off handle for the menu.
1723 \value Margin The margin of the menu.
1724 \value EmptyArea The empty area of the menu.
1725
1726 \sa menuItemType
1727*/
1728
1729/*!
1730 \enum QStyleOptionMenuItem::CheckType
1731
1732 This enum is used to indicate whether or not a check mark should be
1733 drawn for the item, or even if it should be drawn at all.
1734
1735 \value NotCheckable The item is not checkable.
1736 \value Exclusive The item is an exclusive check item (like a radio button).
1737 \value NonExclusive The item is a non-exclusive check item (like a check box).
1738
1739 \sa checkType, QAction::checkable, QAction::checked, QActionGroup::exclusionPolicy
1740*/
1741
1742/*!
1743 \variable QStyleOptionMenuItem::menuItemType
1744 \brief the type of menu item
1745
1746 The default value is \l Normal.
1747
1748 \sa MenuItemType
1749*/
1750
1751/*!
1752 \variable QStyleOptionMenuItem::checkType
1753 \brief the type of checkmark of the menu item
1754
1755 The default value is \l NotCheckable.
1756
1757 \sa CheckType
1758*/
1759
1760/*!
1761 \variable QStyleOptionMenuItem::checked
1762 \brief whether the menu item is checked or not
1763
1764 The default value is false.
1765*/
1766
1767/*!
1768 \variable QStyleOptionMenuItem::menuHasCheckableItems
1769 \brief whether the menu as a whole has checkable items or not
1770
1771 The default value is true.
1772
1773 If this option is set to false, then the menu has no checkable
1774 items. This makes it possible for GUI styles to save some
1775 horizontal space that would normally be used for the check column.
1776*/
1777
1778/*!
1779 \variable QStyleOptionMenuItem::menuRect
1780 \brief the rectangle for the entire menu
1781
1782 The default value is a null rectangle, i.e. a rectangle with both
1783 the width and the height set to 0.
1784*/
1785
1786/*!
1787 \variable QStyleOptionMenuItem::text
1788 \brief the text for the menu item
1789
1790 Note that the text format is something like this "Menu
1791 text\b{\\t}Shortcut".
1792
1793 If the menu item doesn't have a shortcut, it will just contain the
1794 menu item's text. The default value is an empty string.
1795*/
1796
1797/*!
1798 \variable QStyleOptionMenuItem::icon
1799 \brief the icon for the menu item
1800
1801 The default value is an empty icon, i.e. an icon with neither a
1802 pixmap nor a filename.
1803*/
1804
1805/*!
1806 \variable QStyleOptionMenuItem::maxIconWidth
1807 \brief the maximum icon width for the icon in the menu item
1808
1809 This can be used for drawing the icon into the correct place or
1810 properly aligning items. The variable must be set regardless of
1811 whether or not the menu item has an icon. The default value is 0.
1812*/
1813
1814/*!
1815 \variable QStyleOptionMenuItem::reservedShortcutWidth
1816 \brief the reserved width for the menu item's shortcut
1817
1818 QMenu sets it to the width occupied by the widest shortcut among
1819 all visible items within the menu.
1820
1821 The default value is 0.
1822*/
1823
1824
1825/*!
1826 \variable QStyleOptionMenuItem::font
1827 \brief the font used for the menu item text
1828
1829 This is the font that should be used for drawing the menu text
1830 minus the shortcut. The shortcut is usually drawn using the
1831 painter's font. By default, the application's default font is
1832 used.
1833*/
1834
1835/*!
1836 \class QStyleOptionComplex
1837 \brief The QStyleOptionComplex class is used to hold parameters that are
1838 common to all complex controls.
1839
1840 \inmodule QtWidgets
1841
1842 This class is not used on its own. Instead it is used to derive
1843 other complex control options, for example QStyleOptionSlider and
1844 QStyleOptionSpinBox.
1845
1846 For performance reasons, there are few member functions and the
1847 access to the member variables is direct (i.e., using the \c . or
1848 \c -> operator). This makes the structures straightforward to use
1849 and emphasizes that these are simply parameters used by the style
1850 functions.
1851
1852 For an example demonstrating how style options can be used, see
1853 the \l {widgets/styles}{Styles} example.
1854
1855 \sa QStyleOption
1856*/
1857
1858/*!
1859 Constructs a QStyleOptionComplex of the specified \a type and \a
1860 version, initializing the member variables to their default
1861 values. This constructor is usually called by subclasses.
1862*/
1863
1864QStyleOptionComplex::QStyleOptionComplex(int version, int type)
1865 : QStyleOption(version, type), subControls(QStyle::SC_All), activeSubControls(QStyle::SC_None)
1866{
1867}
1868
1869/*!
1870 \fn QStyleOptionComplex::QStyleOptionComplex(const QStyleOptionComplex &other)
1871
1872 Constructs a copy of the \a other style option.
1873*/
1874
1875/*!
1876 \enum QStyleOptionComplex::StyleOptionType
1877
1878 This enum is used to hold information about the type of the style option, and
1879 is defined for each QStyleOption subclass.
1880
1881 \value Type The type of style option provided (\l{SO_Complex} for this class).
1882
1883 The type is used internally by QStyleOption, its subclasses, and
1884 qstyleoption_cast() to determine the type of style option. In
1885 general you do not need to worry about this unless you want to
1886 create your own QStyleOption subclass and your own styles.
1887
1888 \sa StyleOptionVersion
1889*/
1890
1891/*!
1892 \enum QStyleOptionComplex::StyleOptionVersion
1893
1894 This enum is used to hold information about the version of the style option, and
1895 is defined for each QStyleOption subclass.
1896
1897 \value Version 1
1898
1899 The version is used by QStyleOption subclasses to implement
1900 extensions without breaking compatibility. If you use
1901 qstyleoption_cast(), you normally do not need to check it.
1902
1903 \sa StyleOptionType
1904*/
1905
1906/*!
1907 \variable QStyleOptionComplex::subControls
1908
1909 This variable holds a bitwise OR of the \l{QStyle::SubControl}
1910 {sub-controls} to be drawn for the complex control.
1911
1912 The default value is QStyle::SC_All.
1913
1914 \sa QStyle::SubControl
1915*/
1916
1917/*!
1918 \variable QStyleOptionComplex::activeSubControls
1919
1920 This variable holds a bitwise OR of the \l{QStyle::SubControl}
1921 {sub-controls} that are active for the complex control.
1922
1923 The default value is QStyle::SC_None.
1924
1925 \sa QStyle::SubControl
1926*/
1927
1928#if QT_CONFIG(slider)
1929/*!
1930 \class QStyleOptionSlider
1931 \brief The QStyleOptionSlider class is used to describe the
1932 parameters needed for drawing a slider.
1933
1934 \inmodule QtWidgets
1935
1936 QStyleOptionSlider contains all the information that QStyle
1937 functions need to draw QSlider and QScrollBar.
1938
1939 For performance reasons, there are few member functions and the
1940 access to the member variables is direct (i.e., using the \c . or
1941 \c -> operator). This makes the structures straightforward to use
1942 and emphasizes that these are simply parameters used by the style
1943 functions.
1944
1945 For an example demonstrating how style options can be used, see
1946 the \l {widgets/styles}{Styles} example.
1947
1948 \sa QStyleOptionComplex, QSlider, QScrollBar
1949*/
1950
1951/*!
1952 Constructs a QStyleOptionSlider, initializing the members
1953 variables to their default values.
1954*/
1955
1956QStyleOptionSlider::QStyleOptionSlider()
1957 : QStyleOptionComplex(Version, SO_Slider), orientation(Qt::Horizontal), minimum(0), maximum(0),
1958 tickPosition(QSlider::NoTicks), tickInterval(0), upsideDown(false),
1959 sliderPosition(0), sliderValue(0), singleStep(0), pageStep(0), notchTarget(0.0),
1960 dialWrapping(false), keyboardModifiers{}
1961{
1962}
1963
1964/*!
1965 \internal
1966*/
1967QStyleOptionSlider::QStyleOptionSlider(int version)
1968 : QStyleOptionComplex(version, SO_Slider), orientation(Qt::Horizontal), minimum(0), maximum(0),
1969 tickPosition(QSlider::NoTicks), tickInterval(0), upsideDown(false),
1970 sliderPosition(0), sliderValue(0), singleStep(0), pageStep(0), notchTarget(0.0),
1971 dialWrapping(false), keyboardModifiers{}
1972{
1973}
1974
1975/*!
1976 \fn QStyleOptionSlider::QStyleOptionSlider(const QStyleOptionSlider &other)
1977
1978 Constructs a copy of the \a other style option.
1979*/
1980
1981/*!
1982 \enum QStyleOptionSlider::StyleOptionType
1983
1984 This enum is used to hold information about the type of the style option, and
1985 is defined for each QStyleOption subclass.
1986
1987 \value Type The type of style option provided (\l{SO_Slider} for this class).
1988
1989 The type is used internally by QStyleOption, its subclasses, and
1990 qstyleoption_cast() to determine the type of style option. In
1991 general you do not need to worry about this unless you want to
1992 create your own QStyleOption subclass and your own styles.
1993
1994 \sa StyleOptionVersion
1995*/
1996
1997/*!
1998 \enum QStyleOptionSlider::StyleOptionVersion
1999
2000 This enum is used to hold information about the version of the style option, and
2001 is defined for each QStyleOption subclass.
2002
2003 \value Version 1
2004
2005 The version is used by QStyleOption subclasses to implement
2006 extensions without breaking compatibility. If you use
2007 qstyleoption_cast(), you normally do not need to check it.
2008
2009 \sa StyleOptionType
2010*/
2011
2012/*!
2013 \variable QStyleOptionSlider::orientation
2014 \brief the slider's orientation (horizontal or vertical)
2015
2016 The default orientation is Qt::Horizontal.
2017
2018 \sa Qt::Orientation
2019*/
2020
2021/*!
2022 \variable QStyleOptionSlider::minimum
2023 \brief the minimum value for the slider
2024
2025 The default value is 0.
2026*/
2027
2028/*!
2029 \variable QStyleOptionSlider::maximum
2030 \brief the maximum value for the slider
2031
2032 The default value is 0.
2033*/
2034
2035/*!
2036 \variable QStyleOptionSlider::tickPosition
2037 \brief the position of the slider's tick marks, if any
2038
2039 The default value is QSlider::NoTicks.
2040
2041 \sa QSlider::TickPosition
2042*/
2043
2044/*!
2045 \variable QStyleOptionSlider::tickInterval
2046 \brief the interval that should be drawn between tick marks
2047
2048 The default value is 0.
2049*/
2050
2051/*!
2052 \variable QStyleOptionSlider::notchTarget
2053 \brief the number of pixel between notches
2054
2055 The default value is 0.0.
2056
2057 \sa QDial::notchTarget()
2058*/
2059
2060/*!
2061 \variable QStyleOptionSlider::dialWrapping
2062 \brief whether the dial should wrap or not
2063
2064 The default value is false, i.e. the dial is not wrapped.
2065
2066 \sa QDial::wrapping()
2067*/
2068
2069/*!
2070 \variable QStyleOptionSlider::upsideDown
2071 \brief the slider control orientation
2072
2073 Normally a slider increases as it moves up or to the right;
2074 upsideDown indicates that it should do the opposite (increase as
2075 it moves down or to the left). The default value is false,
2076 i.e. the slider increases as it moves up or to the right.
2077
2078 \sa QStyle::sliderPositionFromValue(),
2079 QStyle::sliderValueFromPosition(),
2080 QAbstractSlider::invertedAppearance
2081*/
2082
2083/*!
2084 \variable QStyleOptionSlider::sliderPosition
2085 \brief the position of the slider handle
2086
2087 If the slider has active feedback (i.e.,
2088 QAbstractSlider::tracking is true), this value will be the same as
2089 \l sliderValue. Otherwise, it will have the current position of
2090 the handle. The default value is 0.
2091
2092 \sa QAbstractSlider::tracking, sliderValue
2093*/
2094
2095/*!
2096 \variable QStyleOptionSlider::sliderValue
2097 \brief the value of the slider
2098
2099 If the slider has active feedback (i.e.,
2100 QAbstractSlider::tracking is true), this value will be the same
2101 as \l sliderPosition. Otherwise, it will have the value the
2102 slider had before the mouse was pressed.
2103
2104 The default value is 0.
2105
2106 \sa QAbstractSlider::tracking, sliderPosition
2107*/
2108
2109/*!
2110 \variable QStyleOptionSlider::singleStep
2111 \brief the size of the single step of the slider
2112
2113 The default value is 0.
2114
2115 \sa QAbstractSlider::singleStep
2116*/
2117
2118/*!
2119 \variable QStyleOptionSlider::pageStep
2120 \brief the size of the page step of the slider
2121
2122 The default value is 0.
2123
2124 \sa QAbstractSlider::pageStep
2125*/
2126#endif // QT_CONFIG(slider)
2127
2128#if QT_CONFIG(spinbox)
2129/*!
2130 \class QStyleOptionSpinBox
2131 \brief The QStyleOptionSpinBox class is used to describe the
2132 parameters necessary for drawing a spin box.
2133
2134 \inmodule QtWidgets
2135
2136 QStyleOptionSpinBox contains all the information that QStyle
2137 functions need to draw QSpinBox and QDateTimeEdit.
2138
2139 For performance reasons, there are few member functions and the
2140 access to the member variables is direct (i.e., using the \c . or
2141 \c -> operator). This makes the structures straightforward to use
2142 and emphasizes that these are simply parameters used by the style
2143 functions.
2144
2145 For an example demonstrating how style options can be used, see
2146 the \l {widgets/styles}{Styles} example.
2147
2148 \sa QStyleOption, QStyleOptionComplex
2149*/
2150
2151/*!
2152 Constructs a QStyleOptionSpinBox, initializing the members
2153 variables to their default values.
2154*/
2155
2156QStyleOptionSpinBox::QStyleOptionSpinBox()
2157 : QStyleOptionComplex(Version, SO_SpinBox), buttonSymbols(QAbstractSpinBox::UpDownArrows),
2158 stepEnabled(QAbstractSpinBox::StepNone), frame(false)
2159{
2160}
2161
2162/*!
2163 \internal
2164*/
2165QStyleOptionSpinBox::QStyleOptionSpinBox(int version)
2166 : QStyleOptionComplex(version, SO_SpinBox), buttonSymbols(QAbstractSpinBox::UpDownArrows),
2167 stepEnabled(QAbstractSpinBox::StepNone), frame(false)
2168{
2169}
2170
2171/*!
2172 \fn QStyleOptionSpinBox::QStyleOptionSpinBox(const QStyleOptionSpinBox &other)
2173
2174 Constructs a copy of the \a other style option.
2175*/
2176
2177/*!
2178 \enum QStyleOptionSpinBox::StyleOptionType
2179
2180 This enum is used to hold information about the type of the style option, and
2181 is defined for each QStyleOption subclass.
2182
2183 \value Type The type of style option provided (\l{SO_SpinBox} for this class).
2184
2185 The type is used internally by QStyleOption, its subclasses, and
2186 qstyleoption_cast() to determine the type of style option. In
2187 general you do not need to worry about this unless you want to
2188 create your own QStyleOption subclass and your own styles.
2189
2190 \sa StyleOptionVersion
2191*/
2192
2193/*!
2194 \enum QStyleOptionSpinBox::StyleOptionVersion
2195
2196 This enum is used to hold information about the version of the style option, and
2197 is defined for each QStyleOption subclass.
2198
2199 \value Version 1
2200
2201 The version is used by QStyleOption subclasses to implement
2202 extensions without breaking compatibility. If you use
2203 qstyleoption_cast(), you normally do not need to check it.
2204
2205 \sa StyleOptionType
2206*/
2207
2208/*!
2209 \variable QStyleOptionSpinBox::buttonSymbols
2210 \brief the type of button symbols to draw for the spin box
2211
2212 The default value is QAbstractSpinBox::UpDownArrows specufying
2213 little arrows in the classic style.
2214
2215 \sa QAbstractSpinBox::ButtonSymbols
2216*/
2217
2218/*!
2219 \variable QStyleOptionSpinBox::stepEnabled
2220 \brief which buttons of the spin box that are enabled
2221
2222 The default value is QAbstractSpinBox::StepNone.
2223
2224 \sa QAbstractSpinBox::StepEnabled
2225*/
2226
2227/*!
2228 \variable QStyleOptionSpinBox::frame
2229 \brief whether the spin box has a frame
2230
2231 The default value is false, i.e. the spin box has no frame.
2232*/
2233#endif // QT_CONFIG(spinbox)
2234
2235/*!
2236 \class QStyleOptionDockWidget
2237 \brief The QStyleOptionDockWidget class is used to describe the
2238 parameters for drawing a dock widget.
2239
2240 \inmodule QtWidgets
2241
2242 QStyleOptionDockWidget contains all the information that QStyle
2243 functions need to draw graphical elements like QDockWidget.
2244
2245 For performance reasons, there are few member functions and the
2246 access to the member variables is direct (i.e., using the \c . or
2247 \c -> operator). This makes the structures straightforward to use
2248 and emphasizes that these are simply parameters used by the style
2249 functions.
2250
2251 For an example demonstrating how style options can be used, see
2252 the \l {widgets/styles}{Styles} example.
2253
2254 \sa QStyleOption
2255*/
2256
2257/*!
2258 Constructs a QStyleOptionDockWidget, initializing the member
2259 variables to their default values.
2260*/
2261
2262QStyleOptionDockWidget::QStyleOptionDockWidget()
2263 : QStyleOption(Version, SO_DockWidget), closable(false),
2264 movable(false), floatable(false), verticalTitleBar(false)
2265{
2266}
2267
2268/*!
2269 \internal
2270*/
2271QStyleOptionDockWidget::QStyleOptionDockWidget(int version)
2272 : QStyleOption(version, SO_DockWidget), closable(false),
2273 movable(false), floatable(false), verticalTitleBar(false)
2274{
2275}
2276
2277/*!
2278 \fn QStyleOptionDockWidget::QStyleOptionDockWidget(const QStyleOptionDockWidget &other)
2279
2280 Constructs a copy of the \a other style option.
2281*/
2282
2283/*!
2284 \enum QStyleOptionDockWidget::StyleOptionType
2285
2286 This enum is used to hold information about the type of the style option, and
2287 is defined for each QStyleOption subclass.
2288
2289 \value Type The type of style option provided (\l{SO_DockWidget} for this class).
2290
2291 The type is used internally by QStyleOption, its subclasses, and
2292 qstyleoption_cast() to determine the type of style option. In
2293 general you do not need to worry about this unless you want to
2294 create your own QStyleOption subclass and your own styles.
2295
2296 \sa StyleOptionVersion
2297*/
2298
2299/*!
2300 \enum QStyleOptionDockWidget::StyleOptionVersion
2301
2302 This enum is used to hold information about the version of the style option, and
2303 is defined for each QStyleOption subclass.
2304
2305 \value Version 2
2306
2307 The version is used by QStyleOption subclasses to implement
2308 extensions without breaking compatibility. If you use
2309 qstyleoption_cast(), you normally do not need to check it.
2310
2311 \sa StyleOptionType
2312*/
2313
2314/*!
2315 \variable QStyleOptionDockWidget::title
2316 \brief the title of the dock window
2317
2318 The default value is an empty string.
2319*/
2320
2321/*!
2322 \variable QStyleOptionDockWidget::closable
2323 \brief whether the dock window is closable
2324
2325 The default value is true.
2326*/
2327
2328/*!
2329 \variable QStyleOptionDockWidget::movable
2330 \brief whether the dock window is movable
2331
2332 The default value is false.
2333*/
2334
2335/*!
2336 \variable QStyleOptionDockWidget::floatable
2337 \brief whether the dock window is floatable
2338
2339 The default value is true.
2340*/
2341
2342/*!
2343 \class QStyleOptionToolButton
2344 \brief The QStyleOptionToolButton class is used to describe the
2345 parameters for drawing a tool button.
2346
2347 \inmodule QtWidgets
2348
2349 QStyleOptionToolButton contains all the information that QStyle
2350 functions need to draw QToolButton.
2351
2352 For performance reasons, there are few member functions and the
2353 access to the member variables is direct (i.e., using the \c . or
2354 \c -> operator). This makes the structures straightforward to use
2355 and emphasizes that these are simply parameters used by the style
2356 functions.
2357
2358 For an example demonstrating how style options can be used, see
2359 the \l {widgets/styles}{Styles} example.
2360
2361 \sa QStyleOption, QStyleOptionComplex, QStyleOptionButton
2362*/
2363
2364/*!
2365 \enum QStyleOptionToolButton::ToolButtonFeature
2366 Describes the various features that a tool button can have.
2367
2368 \value None A normal tool button.
2369 \value Arrow The tool button is an arrow.
2370 \value Menu The tool button has a menu.
2371 \value PopupDelay There is a delay to showing the menu.
2372 \value HasMenu The button has a popup menu.
2373 \value MenuButtonPopup The button should display an arrow to
2374 indicate that a menu is present.
2375
2376 \sa features, QToolButton::toolButtonStyle(), QToolButton::popupMode()
2377*/
2378
2379/*!
2380 Constructs a QStyleOptionToolButton, initializing the members
2381 variables to their default values.
2382*/
2383
2384QStyleOptionToolButton::QStyleOptionToolButton()
2385 : QStyleOptionComplex(Version, SO_ToolButton), features(None), arrowType(Qt::DownArrow)
2386 , toolButtonStyle(Qt::ToolButtonIconOnly)
2387{
2388}
2389
2390/*!
2391 \internal
2392*/
2393QStyleOptionToolButton::QStyleOptionToolButton(int version)
2394 : QStyleOptionComplex(version, SO_ToolButton), features(None), arrowType(Qt::DownArrow)
2395 , toolButtonStyle(Qt::ToolButtonIconOnly)
2396
2397{
2398}
2399
2400/*!
2401 \fn QStyleOptionToolButton::QStyleOptionToolButton(const QStyleOptionToolButton &other)
2402
2403 Constructs a copy of the \a other style option.
2404*/
2405
2406/*!
2407 \enum QStyleOptionToolButton::StyleOptionType
2408
2409 This enum is used to hold information about the type of the style option, and
2410 is defined for each QStyleOption subclass.
2411
2412 \value Type The type of style option provided (\l{SO_ToolButton} for this class).
2413
2414 The type is used internally by QStyleOption, its subclasses, and
2415 qstyleoption_cast() to determine the type of style option. In
2416 general you do not need to worry about this unless you want to
2417 create your own QStyleOption subclass and your own styles.
2418
2419 \sa StyleOptionVersion
2420*/
2421
2422/*!
2423 \enum QStyleOptionToolButton::StyleOptionVersion
2424
2425 This enum is used to hold information about the version of the style option, and
2426 is defined for each QStyleOption subclass.
2427
2428 \value Version 1
2429
2430 The version is used by QStyleOption subclasses to implement
2431 extensions without breaking compatibility. If you use
2432 qstyleoption_cast(), you normally do not need to check it.
2433
2434 \sa StyleOptionType
2435*/
2436
2437/*!
2438 \variable QStyleOptionToolButton::features
2439 \brief an OR combination of the tool button's features
2440
2441 The default value is \l None.
2442
2443 \sa ToolButtonFeature
2444*/
2445
2446/*!
2447 \variable QStyleOptionToolButton::icon
2448 \brief the icon for the tool button
2449
2450 The default value is an empty icon, i.e. an icon with neither a
2451 pixmap nor a filename.
2452
2453 \sa iconSize
2454*/
2455
2456/*!
2457 \variable QStyleOptionToolButton::iconSize
2458 \brief the size of the icon for the tool button
2459
2460 The default value is QSize(-1, -1), i.e. an invalid size.
2461*/
2462
2463/*!
2464 \variable QStyleOptionToolButton::text
2465 \brief the text of the tool button
2466
2467 This value is only used if toolButtonStyle is
2468 Qt::ToolButtonTextUnderIcon, Qt::ToolButtonTextBesideIcon, or
2469 Qt::ToolButtonTextOnly. The default value is an empty string.
2470*/
2471
2472/*!
2473 \variable QStyleOptionToolButton::arrowType
2474 \brief the direction of the arrow for the tool button
2475
2476 This value is only used if \l features includes \l Arrow. The
2477 default value is Qt::DownArrow.
2478*/
2479
2480/*!
2481 \variable QStyleOptionToolButton::toolButtonStyle
2482 \brief a Qt::ToolButtonStyle value describing the appearance of
2483 the tool button
2484
2485 The default value is Qt::ToolButtonIconOnly.
2486
2487 \sa QToolButton::toolButtonStyle()
2488*/
2489
2490/*!
2491 \variable QStyleOptionToolButton::pos
2492 \brief the position of the tool button
2493
2494 The default value is a null point, i.e. (0, 0)
2495*/
2496
2497/*!
2498 \variable QStyleOptionToolButton::font
2499 \brief the font that is used for the text
2500
2501 This value is only used if toolButtonStyle is
2502 Qt::ToolButtonTextUnderIcon, Qt::ToolButtonTextBesideIcon, or
2503 Qt::ToolButtonTextOnly. By default, the application's default font
2504 is used.
2505*/
2506
2507/*!
2508 \class QStyleOptionComboBox
2509 \brief The QStyleOptionComboBox class is used to describe the
2510 parameter for drawing a combobox.
2511
2512 \inmodule QtWidgets
2513
2514 QStyleOptionButton contains all the information that QStyle
2515 functions need to draw QComboBox.
2516
2517 For performance reasons, there are few member functions and the
2518 access to the member variables is direct (i.e., using the \c . or
2519 \c -> operator). This makes the structures straightforward to use
2520 and emphasizes that these are simply parameters used by the style
2521 functions.
2522
2523 For an example demonstrating how style options can be used, see
2524 the \l {widgets/styles}{Styles} example.
2525
2526 \sa QStyleOption, QStyleOptionComplex, QComboBox
2527*/
2528
2529/*!
2530 Creates a QStyleOptionComboBox, initializing the members variables
2531 to their default values.
2532*/
2533
2534QStyleOptionComboBox::QStyleOptionComboBox()
2535 : QStyleOptionComplex(Version, SO_ComboBox), editable(false), frame(true)
2536{
2537}
2538
2539/*!
2540 \internal
2541*/
2542QStyleOptionComboBox::QStyleOptionComboBox(int version)
2543 : QStyleOptionComplex(version, SO_ComboBox), editable(false), frame(true)
2544{
2545}
2546
2547/*!
2548 \fn QStyleOptionComboBox::QStyleOptionComboBox(const QStyleOptionComboBox &other)
2549
2550 Constructs a copy of the \a other style option.
2551*/
2552
2553/*!
2554 \enum QStyleOptionComboBox::StyleOptionType
2555
2556 This enum is used to hold information about the type of the style option, and
2557 is defined for each QStyleOption subclass.
2558
2559 \value Type The type of style option provided (\l{SO_ComboBox} for this class).
2560
2561 The type is used internally by QStyleOption, its subclasses, and
2562 qstyleoption_cast() to determine the type of style option. In
2563 general you do not need to worry about this unless you want to
2564 create your own QStyleOption subclass and your own styles.
2565
2566 \sa StyleOptionVersion
2567*/
2568
2569/*!
2570 \enum QStyleOptionComboBox::StyleOptionVersion
2571
2572 This enum is used to hold information about the version of the style option, and
2573 is defined for each QStyleOption subclass.
2574
2575 \value Version 2
2576
2577 The version is used by QStyleOption subclasses to implement
2578 extensions without breaking compatibility. If you use
2579 qstyleoption_cast(), you normally do not need to check it.
2580
2581 \sa StyleOptionType
2582*/
2583
2584/*!
2585 \variable QStyleOptionComboBox::editable
2586 \brief whether or not the combobox is editable or not
2587
2588 the default
2589 value is false
2590
2591 \sa QComboBox::isEditable()
2592*/
2593
2594
2595/*!
2596 \variable QStyleOptionComboBox::frame
2597 \brief whether the combo box has a frame
2598
2599 The default value is true.
2600*/
2601
2602/*!
2603 \variable QStyleOptionComboBox::currentText
2604 \brief the text for the current item of the combo box
2605
2606 The default value is an empty string.
2607*/
2608
2609/*!
2610 \variable QStyleOptionComboBox::currentIcon
2611 \brief the icon for the current item of the combo box
2612
2613 The default value is an empty icon, i.e. an icon with neither a
2614 pixmap nor a filename.
2615*/
2616
2617/*!
2618 \variable QStyleOptionComboBox::iconSize
2619 \brief the icon size for the current item of the combo box
2620
2621 The default value is QSize(-1, -1), i.e. an invalid size.
2622*/
2623
2624/*!
2625 \variable QStyleOptionComboBox::popupRect
2626 \brief the popup rectangle for the combobox
2627
2628 The default value is a null rectangle, i.e. a rectangle with both
2629 the width and the height set to 0.
2630
2631 This variable is currently unused. You can safely ignore it.
2632
2633 \sa QStyle::SC_ComboBoxListBoxPopup
2634*/
2635
2636/*!
2637 \variable QStyleOptionComboBox::textAlignment
2638 \brief the alignment of the current text in the combo box
2639
2640 The default value is Qt::AlignLeft | Qt::AlignVCenter.
2641*/
2642
2643/*!
2644 \class QStyleOptionToolBox
2645 \brief The QStyleOptionToolBox class is used to describe the
2646 parameters needed for drawing a tool box.
2647
2648 \inmodule QtWidgets
2649
2650 QStyleOptionToolBox contains all the information that QStyle
2651 functions need to draw QToolBox.
2652
2653 For performance reasons, there are few member functions and the
2654 access to the member variables is direct (i.e., using the \c . or
2655 \c -> operator). This makes the structures straightforward to use
2656 and emphasizes that these are simply parameters used by the style
2657 functions.
2658
2659 For an example demonstrating how style options can be used, see
2660 the \l {widgets/styles}{Styles} example.
2661
2662 \sa QStyleOption, QToolBox
2663*/
2664
2665/*!
2666 Creates a QStyleOptionToolBox, initializing the members variables
2667 to their default values.
2668*/
2669
2670QStyleOptionToolBox::QStyleOptionToolBox()
2671 : QStyleOption(Version, SO_ToolBox), position(Beginning), selectedPosition(NotAdjacent)
2672{
2673}
2674
2675/*!
2676 \internal
2677*/
2678QStyleOptionToolBox::QStyleOptionToolBox(int version)
2679 : QStyleOption(version, SO_ToolBox), position(Beginning), selectedPosition(NotAdjacent)
2680{
2681}
2682
2683/*!
2684 \fn QStyleOptionToolBox::QStyleOptionToolBox(const QStyleOptionToolBox &other)
2685
2686 Constructs a copy of the \a other style option.
2687*/
2688
2689/*!
2690 \enum QStyleOptionToolBox::StyleOptionType
2691
2692 This enum is used to hold information about the type of the style option, and
2693 is defined for each QStyleOption subclass.
2694
2695 \value Type The type of style option provided (\l{SO_ToolBox} for this class).
2696
2697 The type is used internally by QStyleOption, its subclasses, and
2698 qstyleoption_cast() to determine the type of style option. In
2699 general you do not need to worry about this unless you want to
2700 create your own QStyleOption subclass and your own styles.
2701
2702 \sa StyleOptionVersion
2703*/
2704
2705/*!
2706 \enum QStyleOptionToolBox::StyleOptionVersion
2707
2708 This enum is used to hold information about the version of the style option, and
2709 is defined for each QStyleOption subclass.
2710
2711 \value Version 2
2712
2713 The version is used by QStyleOption subclasses to implement
2714 extensions without breaking compatibility. If you use
2715 qstyleoption_cast(), you normally do not need to check it.
2716
2717 \sa StyleOptionType
2718*/
2719
2720/*!
2721 \variable QStyleOptionToolBox::icon
2722 \brief the icon for the tool box tab
2723
2724 The default value is an empty icon, i.e. an icon with neither a
2725 pixmap nor a filename.
2726*/
2727
2728/*!
2729 \variable QStyleOptionToolBox::text
2730 \brief the text for the tool box tab
2731
2732 The default value is an empty string.
2733*/
2734
2735/*!
2736 \enum QStyleOptionToolBox::SelectedPosition
2737
2738 This enum describes the position of the selected tab. Some styles
2739 need to draw a tab differently depending on whether or not it is
2740 adjacent to the selected tab.
2741
2742 \value NotAdjacent The tab is not adjacent to a selected tab (or is the selected tab).
2743 \value NextIsSelected The next tab (typically the tab on the right) is selected.
2744 \value PreviousIsSelected The previous tab (typically the tab on the left) is selected.
2745
2746 \sa selectedPosition
2747*/
2748
2749/*!
2750 \enum QStyleOptionToolBox::TabPosition
2751
2752 This enum describes tab positions relative to other tabs.
2753
2754 \value Beginning The tab is the first (i.e., top-most) tab in
2755 the toolbox.
2756 \value Middle The tab is placed in the middle of the toolbox.
2757 \value End The tab is placed at the bottom of the toolbox.
2758 \value OnlyOneTab There is only one tab in the toolbox.
2759*/
2760
2761/*!
2762 \variable QStyleOptionToolBox::selectedPosition
2763 \brief the position of the selected tab in relation to this tab
2764
2765 The default value is NotAdjacent, i.e. the tab is not adjacent to
2766 a selected tab nor is it the selected tab.
2767*/
2768
2769#if QT_CONFIG(rubberband)
2770/*!
2771 \class QStyleOptionRubberBand
2772 \brief The QStyleOptionRubberBand class is used to describe the
2773 parameters needed for drawing a rubber band.
2774
2775 \inmodule QtWidgets
2776
2777 QStyleOptionRubberBand contains all the information that
2778 QStyle functions need to draw QRubberBand.
2779
2780 For performance reasons, there are few member functions and the
2781 access to the member variables is direct (i.e., using the \c . or
2782 \c -> operator). This makes the structures straightforward to use
2783 and emphasizes that these are simply parameters used by the style
2784 functions.
2785
2786 For an example demonstrating how style options can be used, see
2787 the \l {widgets/styles}{Styles} example.
2788
2789 \sa QStyleOption, QRubberBand
2790*/
2791
2792/*!
2793 Creates a QStyleOptionRubberBand, initializing the members
2794 variables to their default values.
2795*/
2796
2797QStyleOptionRubberBand::QStyleOptionRubberBand()
2798 : QStyleOption(Version, SO_RubberBand), shape(QRubberBand::Line), opaque(false)
2799{
2800}
2801
2802/*!
2803 \internal
2804*/
2805QStyleOptionRubberBand::QStyleOptionRubberBand(int version)
2806 : QStyleOption(version, SO_RubberBand), shape(QRubberBand::Line), opaque(false)
2807{
2808}
2809
2810/*!
2811 \fn QStyleOptionRubberBand::QStyleOptionRubberBand(const QStyleOptionRubberBand &other)
2812
2813 Constructs a copy of the \a other style option.
2814*/
2815
2816/*!
2817 \enum QStyleOptionRubberBand::StyleOptionType
2818
2819 This enum is used to hold information about the type of the style option, and
2820 is defined for each QStyleOption subclass.
2821
2822 \value Type The type of style option provided (\l{SO_RubberBand} for this class).
2823
2824 The type is used internally by QStyleOption, its subclasses, and
2825 qstyleoption_cast() to determine the type of style option. In
2826 general you do not need to worry about this unless you want to
2827 create your own QStyleOption subclass and your own styles.
2828
2829 \sa StyleOptionVersion
2830*/
2831
2832/*!
2833 \enum QStyleOptionRubberBand::StyleOptionVersion
2834
2835 This enum is used to hold information about the version of the style option, and
2836 is defined for each QStyleOption subclass.
2837
2838 \value Version 1
2839
2840 The version is used by QStyleOption subclasses to implement
2841 extensions without breaking compatibility. If you use
2842 qstyleoption_cast(), you normally do not need to check it.
2843
2844 \sa StyleOptionType
2845*/
2846
2847/*!
2848 \variable QStyleOptionRubberBand::shape
2849 \brief the shape of the rubber band
2850
2851 The default shape is QRubberBand::Line.
2852*/
2853
2854/*!
2855 \variable QStyleOptionRubberBand::opaque
2856 \brief whether the rubber band is required to be drawn in an opaque style
2857
2858 The default value is true.
2859*/
2860#endif // QT_CONFIG(rubberband)
2861
2862/*!
2863 \class QStyleOptionTitleBar
2864 \brief The QStyleOptionTitleBar class is used to describe the
2865 parameters for drawing a title bar.
2866
2867 \inmodule QtWidgets
2868
2869 QStyleOptionTitleBar contains all the information that QStyle
2870 functions need to draw the title bar of a QMdiSubWindow.
2871
2872 For performance reasons, there are few member functions and the
2873 access to the member variables is direct (i.e., using the \c . or
2874 \c -> operator). This makes the structures straightforward to use
2875 and emphasizes that these are simply parameters used by the style
2876 functions.
2877
2878 For an example demonstrating how style options can be used, see
2879 the \l {widgets/styles}{Styles} example.
2880
2881 \sa QStyleOption, QStyleOptionComplex, QMdiSubWindow
2882*/
2883
2884/*!
2885 Constructs a QStyleOptionTitleBar, initializing the members
2886 variables to their default values.
2887*/
2888
2889QStyleOptionTitleBar::QStyleOptionTitleBar()
2890 : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0)
2891{
2892}
2893
2894/*!
2895 \fn QStyleOptionTitleBar::QStyleOptionTitleBar(const QStyleOptionTitleBar &other)
2896
2897 Constructs a copy of the \a other style option.
2898*/
2899
2900/*!
2901 \enum QStyleOptionTitleBar::StyleOptionType
2902
2903 This enum is used to hold information about the type of the style option, and
2904 is defined for each QStyleOption subclass.
2905
2906 \value Type The type of style option provided (\l{SO_TitleBar} for this class).
2907
2908 The type is used internally by QStyleOption, its subclasses, and
2909 qstyleoption_cast() to determine the type of style option. In
2910 general you do not need to worry about this unless you want to
2911 create your own QStyleOption subclass and your own styles.
2912
2913 \sa StyleOptionVersion
2914*/
2915
2916/*!
2917 \enum QStyleOptionTitleBar::StyleOptionVersion
2918
2919 This enum is used to hold information about the version of the style option, and
2920 is defined for each QStyleOption subclass.
2921
2922 \value Version 1
2923
2924 The version is used by QStyleOption subclasses to implement
2925 extensions without breaking compatibility. If you use
2926 qstyleoption_cast(), you normally do not need to check it.
2927
2928 \sa StyleOptionType
2929*/
2930
2931/*!
2932 \internal
2933*/
2934QStyleOptionTitleBar::QStyleOptionTitleBar(int version)
2935 : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0)
2936{
2937}
2938
2939
2940/*!
2941 \variable QStyleOptionTitleBar::text
2942 \brief the text of the title bar
2943
2944 The default value is an empty string.
2945*/
2946
2947/*!
2948 \variable QStyleOptionTitleBar::icon
2949 \brief the icon for the title bar
2950
2951 The default value is an empty icon, i.e. an icon with neither a
2952 pixmap nor a filename.
2953*/
2954
2955/*!
2956 \variable QStyleOptionTitleBar::titleBarState
2957 \brief the state of the title bar
2958
2959 This is basically the window state of the underlying widget. The
2960 default value is 0.
2961
2962 \sa QWidget::windowState()
2963*/
2964
2965/*!
2966 \variable QStyleOptionTitleBar::titleBarFlags
2967 \brief the widget flags for the title bar
2968
2969 The default value is Qt::Widget.
2970
2971 \sa Qt::WindowFlags
2972*/
2973
2974#if QT_CONFIG(itemviews)
2975/*!
2976 \class QStyleOptionViewItem
2977 \brief The QStyleOptionViewItem class is used to describe the
2978 parameters used to draw an item in a view widget.
2979
2980 \inmodule QtWidgets
2981
2982 QStyleOptionViewItem contains all the information that QStyle
2983 functions need to draw the items for Qt's model/view classes.
2984
2985 For performance reasons, there are few member functions and the
2986 access to the member variables is direct (i.e., using the \c . or
2987 \c -> operator). This makes the structures straightforward to use
2988 and emphasizes that these are simply parameters used by the style
2989 functions.
2990
2991 For an example demonstrating how style options can be used, see
2992 the \l {widgets/styles}{Styles} example.
2993
2994 \sa QStyleOption, {model-view-programming.html}{Model/View
2995 Programming}
2996*/
2997
2998/*!
2999 \enum QStyleOptionViewItem::Position
3000
3001 This enum describes the position of the item's decoration.
3002
3003 \value Left On the left of the text.
3004 \value Right On the right of the text.
3005 \value Top Above the text.
3006 \value Bottom Below the text.
3007
3008 \sa decorationPosition
3009*/
3010
3011/*!
3012 \variable QStyleOptionViewItem::showDecorationSelected
3013 \brief whether the decoration should be highlighted on selected
3014 items
3015
3016 If this option is true, the branch and any decorations on selected items
3017 should be highlighted, indicating that the item is selected; otherwise, no
3018 highlighting is required. The default value is false.
3019
3020 \sa QStyle::SH_ItemView_ShowDecorationSelected, QAbstractItemView
3021*/
3022
3023/*!
3024 \variable QStyleOptionViewItem::textElideMode
3025 \brief where ellipsis should be added for text that is too long to fit
3026 into an item
3027
3028 The default value is Qt::ElideMiddle, i.e. the ellipsis appears in
3029 the middle of the text.
3030
3031 \sa Qt::TextElideMode, QStyle::SH_ItemView_EllipsisLocation
3032*/
3033
3034/*!
3035 Constructs a QStyleOptionViewItem, initializing the members
3036 variables to their default values.
3037*/
3038
3039QStyleOptionViewItem::QStyleOptionViewItem()
3040 : QStyleOption(Version, SO_ViewItem),
3041 displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
3042 textElideMode(Qt::ElideMiddle), decorationPosition(Left),
3043 showDecorationSelected(false), features(None), widget(nullptr),
3044 checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
3045{
3046}
3047
3048/*!
3049 \internal
3050*/
3051QStyleOptionViewItem::QStyleOptionViewItem(int version)
3052 : QStyleOption(version, SO_ViewItem),
3053 displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
3054 textElideMode(Qt::ElideMiddle), decorationPosition(Left),
3055 showDecorationSelected(false), features(None), widget(nullptr),
3056 checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
3057{
3058}
3059
3060/*!
3061 \fn QStyleOptionViewItem::QStyleOptionViewItem(const QStyleOptionViewItem &other)
3062
3063 Constructs a copy of the \a other style option.
3064*/
3065
3066/*!
3067 \enum QStyleOptionViewItem::StyleOptionType
3068
3069 This enum is used to hold information about the type of the style option, and
3070 is defined for each QStyleOption subclass.
3071
3072 \value Type The type of style option provided (\l{SO_ViewItem} for this class).
3073
3074 The type is used internally by QStyleOption, its subclasses, and
3075 qstyleoption_cast() to determine the type of style option. In
3076 general you do not need to worry about this unless you want to
3077 create your own QStyleOption subclass and your own styles.
3078
3079 \sa StyleOptionVersion
3080*/
3081
3082/*!
3083 \enum QStyleOptionViewItem::StyleOptionVersion
3084
3085 This enum is used to hold information about the version of the style option, and
3086 is defined for each QStyleOption subclass.
3087
3088 \value Version 4
3089
3090 The version is used by QStyleOption subclasses to implement
3091 extensions without breaking compatibility. If you use
3092 qstyleoption_cast(), you normally do not need to check it.
3093
3094 \sa StyleOptionType
3095*/
3096
3097/*!
3098 \variable QStyleOptionViewItem::displayAlignment
3099 \brief the alignment of the display value for the item
3100
3101 The default value is Qt::AlignLeft.
3102*/
3103
3104/*!
3105 \variable QStyleOptionViewItem::decorationAlignment
3106 \brief the alignment of the decoration for the item
3107
3108 The default value is Qt::AlignLeft.
3109*/
3110
3111/*!
3112 \variable QStyleOptionViewItem::decorationPosition
3113 \brief the position of the decoration for the item
3114
3115 The default value is \l Left.
3116
3117 \sa Position
3118*/
3119
3120/*!
3121 \variable QStyleOptionViewItem::decorationSize
3122 \brief the size of the decoration for the item
3123
3124 The default value is QSize(-1, -1), i.e. an invalid size.
3125
3126 \sa decorationAlignment, decorationPosition
3127*/
3128
3129/*!
3130 \variable QStyleOptionViewItem::font
3131 \brief the font used for the item
3132
3133 By default, the application's default font is used.
3134
3135 \sa QFont
3136*/
3137
3138/*!
3139 \variable QStyleOptionViewItem::features
3140 \brief a bitwise OR of the features that describe this view item
3141
3142 \sa ViewItemFeature
3143*/
3144
3145/*!
3146 \enum QStyleOptionViewItem::ViewItemFeature
3147
3148 This enum describes the different types of features an item can have.
3149
3150 \value None Indicates a normal item.
3151 \value WrapText Indicates an item with wrapped text.
3152 \value Alternate Indicates that the item's background is rendered using alternateBase.
3153 \value HasCheckIndicator Indicates that the item has a check state indicator.
3154 \value HasDisplay Indicates that the item has a display role.
3155 \value HasDecoration Indicates that the item has a decoration role.
3156*/
3157
3158/*!
3159 \variable QStyleOptionViewItem::index
3160
3161 The model index that is to be drawn.
3162*/
3163
3164/*!
3165 \variable QStyleOptionViewItem::checkState
3166
3167 If this view item is checkable, i.e.,
3168 ViewItemFeature::HasCheckIndicator is true, \c checkState is true
3169 if the item is checked; otherwise, it is false.
3170
3171*/
3172
3173/*!
3174 \variable QStyleOptionViewItem::icon
3175
3176 The icon (if any) to be drawn in the view item.
3177*/
3178
3179
3180/*!
3181 \variable QStyleOptionViewItem::text
3182
3183 The text (if any) to be drawn in the view item.
3184*/
3185
3186/*!
3187 \variable QStyleOptionViewItem::backgroundBrush
3188
3189 The QBrush that should be used to paint the view items
3190 background.
3191*/
3192
3193/*!
3194 \variable QStyleOptionViewItem::viewItemPosition
3195
3196 Gives the position of this view item relative to other items. See
3197 the \l{QStyleOptionViewItem::}{ViewItemPosition} enum for the
3198 details.
3199*/
3200
3201/*!
3202 \enum QStyleOptionViewItem::ViewItemPosition
3203
3204 This enum is used to represent the placement of the item on
3205 a row. This can be used to draw items differently depending
3206 on their placement, for example by putting rounded edges at
3207 the beginning and end, and straight edges in between.
3208
3209 \value Invalid The ViewItemPosition is unknown and should be
3210 disregarded.
3211 \value Beginning The item appears at the beginning of the row.
3212 \value Middle The item appears in the middle of the row.
3213 \value End The item appears at the end of the row.
3214 \value OnlyOne The item is the only one on the row, and is
3215 therefore both at the beginning and the end.
3216*/
3217
3218#endif // QT_CONFIG(itemviews)
3219/*!
3220 \fn template <typename T> T qstyleoption_cast<T>(const QStyleOption *option)
3221 \relates QStyleOption
3222
3223 Returns a T or \nullptr depending on the \l{QStyleOption::type}{type} and
3224 \l{QStyleOption::version}{version} of the given \a option.
3225
3226 Example:
3227
3228 \snippet qstyleoption/main.cpp 4
3229
3230 \sa QStyleOption::type, QStyleOption::version
3231*/
3232
3233/*!
3234 \fn template <typename T> T qstyleoption_cast<T>(QStyleOption *option)
3235 \overload
3236 \relates QStyleOption
3237
3238 Returns a T or \nullptr depending on the type of the given \a option.
3239*/
3240
3241#if QT_CONFIG(tabwidget)
3242/*!
3243 \class QStyleOptionTabWidgetFrame
3244 \brief The QStyleOptionTabWidgetFrame class is used to describe the
3245 parameters for drawing the frame around a tab widget.
3246
3247 \inmodule QtWidgets
3248
3249 QStyleOptionTabWidgetFrame contains all the information that
3250 QStyle functions need to draw the frame around QTabWidget.
3251
3252 For performance reasons, there are few member functions and the
3253 access to the member variables is direct (i.e., using the \c . or
3254 \c -> operator). This makes the structures straightforward to use
3255 and emphasizes that these are simply parameters used by the style
3256 functions.
3257
3258 For an example demonstrating how style options can be used, see
3259 the \l {widgets/styles}{Styles} example.
3260
3261 \sa QStyleOption, QTabWidget
3262*/
3263
3264/*!
3265 Constructs a QStyleOptionTabWidgetFrame, initializing the members
3266 variables to their default values.
3267*/
3268QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame()
3269 : QStyleOption(Version, SO_TabWidgetFrame), lineWidth(0), midLineWidth(0),
3270 shape(QTabBar::RoundedNorth)
3271{
3272}
3273
3274/*!
3275 \fn QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
3276
3277 Constructs a copy of \a other.
3278*/
3279
3280/*! \internal */
3281QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame(int version)
3282 : QStyleOption(version, SO_TabWidgetFrame), lineWidth(0), midLineWidth(0),
3283 shape(QTabBar::RoundedNorth)
3284{
3285}
3286
3287/*!
3288 \enum QStyleOptionTabWidgetFrame::StyleOptionType
3289
3290 This enum is used to hold information about the type of the style option, and
3291 is defined for each QStyleOption subclass.
3292
3293 \value Type The type of style option provided (\l{SO_TabWidgetFrame} for this class).
3294
3295 The type is used internally by QStyleOption, its subclasses, and
3296 qstyleoption_cast() to determine the type of style option. In
3297 general you do not need to worry about this unless you want to
3298 create your own QStyleOption subclass and your own styles.
3299
3300 \sa StyleOptionVersion
3301*/
3302
3303/*!
3304 \enum QStyleOptionTabWidgetFrame::StyleOptionVersion
3305
3306 This enum is used to hold information about the version of the style option, and
3307 is defined for each QStyleOption subclass.
3308
3309 \value Version 2
3310
3311 The version is used by QStyleOption subclasses to implement
3312 extensions without breaking compatibility. If you use
3313 qstyleoption_cast(), you normally do not need to check it.
3314
3315 \sa StyleOptionType
3316*/
3317
3318/*!
3319 \variable QStyleOptionTabWidgetFrame::lineWidth
3320 \brief the line width for drawing the panel
3321
3322 The default value is 0.
3323*/
3324
3325/*!
3326 \variable QStyleOptionTabWidgetFrame::midLineWidth
3327 \brief the mid-line width for drawing the panel
3328
3329 The mid line width is usually used in drawing sunken or raised
3330 frames. The default value is 0.
3331*/
3332
3333/*!
3334 \variable QStyleOptionTabWidgetFrame::shape
3335 \brief the tab shape used to draw the tabs
3336
3337 The default value is QTabBar::RoundedNorth.
3338*/
3339
3340/*!
3341 \variable QStyleOptionTabWidgetFrame::tabBarSize
3342 \brief the size of the tab bar
3343
3344 The default value is QSize(-1, -1), i.e. an invalid size.
3345*/
3346
3347/*!
3348 \variable QStyleOptionTabWidgetFrame::rightCornerWidgetSize
3349 \brief the size of the right-corner widget
3350
3351 The default value is QSize(-1, -1), i.e. an invalid size.
3352*/
3353
3354/*! \variable QStyleOptionTabWidgetFrame::leftCornerWidgetSize
3355 \brief the size of the left-corner widget
3356
3357 The default value is QSize(-1, -1), i.e. an invalid size.
3358*/
3359
3360
3361/*!
3362 \variable QStyleOptionTabWidgetFrame::tabBarRect
3363 \brief the rectangle containing all the tabs
3364
3365 The default value is a null rectangle, i.e. a rectangle with both
3366 the width and the height set to 0.
3367*/
3368
3369/*!
3370 \variable QStyleOptionTabWidgetFrame::selectedTabRect
3371 \brief the rectangle containing the selected tab
3372
3373 This rectangle is contained within the tabBarRect. The default
3374 value is a null rectangle, i.e. a rectangle with both the width
3375 and the height set to 0.
3376*/
3377
3378#endif // QT_CONFIG(tabwidget)
3379
3380#if QT_CONFIG(tabbar)
3381
3382/*!
3383 \class QStyleOptionTabBarBase
3384 \brief The QStyleOptionTabBarBase class is used to describe
3385 the base of a tab bar, i.e. the part that the tab bar usually
3386 overlaps with.
3387
3388 \inmodule QtWidgets
3389
3390 QStyleOptionTabBarBase contains all the information that QStyle
3391 functions need to draw the tab bar base. Note that this is only
3392 drawn for a standalone QTabBar (one that isn't part of a
3393 QTabWidget).
3394
3395 For performance reasons, there are few member functions and the
3396 access to the member variables is direct (i.e., using the \c . or
3397 \c -> operator). This makes the structures straightforward to use
3398 and emphasizes that these are simply parameters used by the style
3399 functions.
3400
3401 For an example demonstrating how style options can be used, see
3402 the \l {widgets/styles}{Styles} example.
3403
3404 \sa QStyleOption, QTabBar::drawBase()
3405*/
3406
3407/*!
3408 Construct a QStyleOptionTabBarBase, initializing the members
3409 vaiables to their default values.
3410*/
3411QStyleOptionTabBarBase::QStyleOptionTabBarBase()
3412 : QStyleOption(Version, SO_TabBarBase), shape(QTabBar::RoundedNorth),
3413 documentMode(false)
3414{
3415}
3416
3417/*! \internal */
3418QStyleOptionTabBarBase::QStyleOptionTabBarBase(int version)
3419 : QStyleOption(version, SO_TabBarBase), shape(QTabBar::RoundedNorth),
3420 documentMode(false)
3421{
3422}
3423
3424/*!
3425 \fn QStyleOptionTabBarBase::QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other)
3426
3427 Constructs a copy of \a other.
3428*/
3429
3430/*!
3431 \enum QStyleOptionTabBarBase::StyleOptionType
3432
3433 This enum is used to hold information about the type of the style option, and
3434 is defined for each QStyleOption subclass.
3435
3436 \value Type The type of style option provided (\l{SO_TabBarBase} for this class).
3437
3438 The type is used internally by QStyleOption, its subclasses, and
3439 qstyleoption_cast() to determine the type of style option. In
3440 general you do not need to worry about this unless you want to
3441 create your own QStyleOption subclass and your own styles.
3442
3443 \sa StyleOptionVersion
3444*/
3445
3446/*!
3447 \enum QStyleOptionTabBarBase::StyleOptionVersion
3448
3449 This enum is used to hold information about the version of the style option, and
3450 is defined for each QStyleOption subclass.
3451
3452 \value Version 2
3453
3454 The version is used by QStyleOption subclasses to implement
3455 extensions without breaking compatibility. If you use
3456 qstyleoption_cast(), you normally do not need to check it.
3457
3458 \sa StyleOptionType
3459*/
3460
3461/*!
3462 \variable QStyleOptionTabBarBase::shape
3463 \brief the shape of the tab bar
3464
3465 The default value is QTabBar::RoundedNorth.
3466*/
3467
3468/*!
3469 \variable QStyleOptionTabBarBase::tabBarRect
3470 \brief the rectangle containing all the tabs
3471
3472 The default value is a null rectangle, i.e. a rectangle with both
3473 the width and the height set to 0.
3474*/
3475
3476/*!
3477 \variable QStyleOptionTabBarBase::selectedTabRect
3478 \brief the rectangle containing the selected tab
3479
3480 This rectangle is contained within the tabBarRect. The default
3481 value is a null rectangle, i.e. a rectangle with both the width
3482 and the height set to 0.
3483*/
3484
3485
3486/*!
3487 \variable QStyleOptionTabBarBase::documentMode
3488 \brief whether the tabbar is in document mode.
3489
3490 The default value is false;
3491*/
3492
3493#endif // QT_CONFIG(tabbar)
3494
3495#if QT_CONFIG(sizegrip)
3496/*!
3497 \class QStyleOptionSizeGrip
3498 \brief The QStyleOptionSizeGrip class is used to describe the
3499 parameter for drawing a size grip.
3500 \since 4.2
3501 \inmodule QtWidgets
3502
3503 QStyleOptionButton contains all the information that QStyle
3504 functions need to draw QSizeGrip.
3505
3506 For performance reasons, there are few member functions and the
3507 access to the member variables is direct (i.e., using the \c . or
3508 \c -> operator). This makes the structures straightforward to use
3509 and emphasizes that these are simply parameters used by the style
3510 functions.
3511
3512 For an example demonstrating how style options can be used, see
3513 the \l {widgets/styles}{Styles} example.
3514
3515 \sa QStyleOption, QStyleOptionComplex, QSizeGrip
3516*/
3517
3518/*!
3519 Constructs a QStyleOptionSizeGrip.
3520*/
3521QStyleOptionSizeGrip::QStyleOptionSizeGrip()
3522 : QStyleOptionComplex(Version, Type), corner(Qt::BottomRightCorner)
3523{
3524}
3525
3526/*!
3527 \fn QStyleOptionSizeGrip::QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other)
3528
3529 Constructs a copy of the \a other style option.
3530*/
3531
3532/*!
3533 \internal
3534*/
3535QStyleOptionSizeGrip::QStyleOptionSizeGrip(int version)
3536 : QStyleOptionComplex(version, Type), corner(Qt::BottomRightCorner)
3537{
3538}
3539
3540/*!
3541 \variable QStyleOptionSizeGrip::corner
3542
3543 The corner in which the size grip is located.
3544*/
3545
3546/*!
3547 \enum QStyleOptionSizeGrip::StyleOptionType
3548
3549 This enum is used to hold information about the type of the style option, and
3550 is defined for each QStyleOption subclass.
3551
3552 \value Type The type of style option provided (\l{SO_TabBarBase} for this class).
3553
3554 The type is used internally by QStyleOption, its subclasses, and
3555 qstyleoption_cast() to determine the type of style option. In
3556 general you do not need to worry about this unless you want to
3557 create your own QStyleOption subclass and your own styles.
3558
3559 \sa StyleOptionVersion
3560*/
3561
3562/*!
3563 \enum QStyleOptionSizeGrip::StyleOptionVersion
3564
3565 This enum is used to hold information about the version of the style option, and
3566 is defined for each QStyleOption subclass.
3567
3568 \value Version 1
3569
3570 The version is used by QStyleOption subclasses to implement
3571 extensions without breaking compatibility. If you use
3572 qstyleoption_cast(), you normally do not need to check it.
3573
3574 \sa StyleOptionType
3575*/
3576#endif // QT_CONFIG(sizegrip)
3577
3578/*!
3579 \class QStyleOptionGraphicsItem
3580 \brief The QStyleOptionGraphicsItem class is used to describe
3581 the parameters needed to draw a QGraphicsItem.
3582 \since 4.2
3583 \ingroup graphicsview-api
3584 \inmodule QtWidgets
3585
3586 For performance reasons, there are few member functions and the
3587 access to the member variables is direct (i.e., using the \c . or
3588 \c -> operator). This makes the structures straightforward to use
3589 and emphasizes that these are simply parameters used by the style
3590 functions.
3591
3592 For an example demonstrating how style options can be used, see
3593 the \l {widgets/styles}{Styles} example.
3594
3595 \sa QStyleOption, QGraphicsItem::paint()
3596*/
3597
3598/*!
3599 \enum QStyleOptionGraphicsItem::StyleOptionType
3600
3601 This enum is used to hold information about the type of the style option, and
3602 is defined for each QStyleOption subclass.
3603
3604 \value Type The type of style option provided (\l SO_GraphicsItem for this class).
3605
3606 The type is used internally by QStyleOption, its subclasses, and
3607 qstyleoption_cast() to determine the type of style option. In
3608 general you do not need to worry about this unless you want to
3609 create your own QStyleOption subclass and your own styles.
3610
3611 \sa StyleOptionVersion
3612*/
3613
3614/*!
3615 \enum QStyleOptionGraphicsItem::StyleOptionVersion
3616
3617 This enum is used to hold information about the version of the style option, and
3618 is defined for each QStyleOption subclass.
3619
3620 \value Version 1
3621
3622 The version is used by QStyleOption subclasses to implement
3623 extensions without breaking compatibility. If you use
3624 qstyleoption_cast(), you normally do not need to check it.
3625
3626 \sa StyleOptionType
3627*/
3628
3629/*!
3630 Constructs a QStyleOptionGraphicsItem.
3631*/
3632QStyleOptionGraphicsItem::QStyleOptionGraphicsItem()
3633 : QStyleOption(Version, Type)
3634{
3635}
3636
3637/*!
3638 \internal
3639*/
3640QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(int version)
3641 : QStyleOption(version, Type)
3642{
3643}
3644
3645/*!
3646 \since 4.6
3647
3648 Returns the level of detail from the \a worldTransform.
3649
3650 Its value represents the maximum value of the height and
3651 width of a unity rectangle, mapped using the \a worldTransform
3652 of the painter used to draw the item. By default, if no
3653 transformations are applied, its value is 1. If zoomed out 1:2, the level
3654 of detail will be 0.5, and if zoomed in 2:1, its value is 2.
3655
3656 \sa QGraphicsScene::minimumRenderSize()
3657*/
3658qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &worldTransform)
3659{
3660 if (worldTransform.type() <= QTransform::TxTranslate)
3661 return 1; // Translation only? The LOD is 1.
3662
3663 // Two unit vectors.
3664 QLineF v1(0, 0, 1, 0);
3665 QLineF v2(0, 0, 0, 1);
3666 // LOD is the transformed area of a 1x1 rectangle.
3667 return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length());
3668}
3669
3670/*!
3671 \fn QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other)
3672
3673 Constructs a copy of \a other.
3674*/
3675
3676/*!
3677 \variable QStyleOptionGraphicsItem::exposedRect
3678 \brief the exposed rectangle, in item coordinates
3679
3680 Make use of this rectangle to speed up item drawing when only parts of the
3681 item are exposed. If the whole item is exposed, this rectangle will be the
3682 same as QGraphicsItem::boundingRect().
3683
3684 This member is only initialized for items that have the
3685 QGraphicsItem::ItemUsesExtendedStyleOption flag set.
3686*/
3687
3688/*!
3689 \class QStyleHintReturn
3690 \brief The QStyleHintReturn class provides style hints that return more
3691 than basic data types.
3692
3693 \ingroup appearance
3694 \inmodule QtWidgets
3695
3696 QStyleHintReturn and its subclasses are used to pass information
3697 from a style back to the querying widget. This is most useful
3698 when the return value from QStyle::styleHint() does not provide enough
3699 detail; for example, when a mask is to be returned.
3700*/
3701
3702/*!
3703 \enum QStyleHintReturn::HintReturnType
3704
3705 \value SH_Default QStyleHintReturn
3706 \value SH_Mask \l QStyle::SH_RubberBand_Mask QStyle::SH_FocusFrame_Mask
3707 \value SH_Variant \l QStyle::SH_TextControl_FocusIndicatorTextCharFormat
3708*/
3709
3710/*!
3711 \enum QStyleHintReturn::StyleOptionType
3712
3713 This enum is used to hold information about the type of the style option, and
3714 is defined for each QStyleHintReturn subclass.
3715
3716 \value Type The type of style option provided (\l SH_Default for
3717 this class).
3718
3719 The type is used internally by QStyleHintReturn, its subclasses, and
3720 qstyleoption_cast() to determine the type of style option. In
3721 general you do not need to worry about this unless you want to
3722 create your own QStyleHintReturn subclass and your own styles.
3723
3724 \sa StyleOptionVersion
3725*/
3726
3727/*!
3728 \enum QStyleHintReturn::StyleOptionVersion
3729
3730 This enum is used to hold information about the version of the style option, and
3731 is defined for each QStyleHintReturn subclass.
3732
3733 \value Version 1
3734
3735 The version is used by QStyleHintReturn subclasses to implement
3736 extensions without breaking compatibility. If you use
3737 qstyleoption_cast(), you normally do not need to check it.
3738
3739 \sa StyleOptionType
3740*/
3741
3742/*!
3743 \variable QStyleHintReturn::type
3744 \brief the type of the style hint container
3745
3746 \sa HintReturnType
3747*/
3748
3749/*!
3750 \variable QStyleHintReturn::version
3751 \brief the version of the style hint return container
3752
3753 This value can be used by subclasses to implement extensions
3754 without breaking compatibility. If you use qstyleoption_cast<T>(), you
3755 normally do not need to check it.
3756*/
3757
3758/*!
3759 Constructs a QStyleHintReturn with version \a version and type \a
3760 type.
3761
3762 The version has no special meaning for QStyleHintReturn; it can be
3763 used by subclasses to distinguish between different version of
3764 the same hint type.
3765
3766 \sa QStyleOption::version, QStyleOption::type
3767*/
3768
3769QStyleHintReturn::QStyleHintReturn(int version, int type)
3770 : version(version), type(type)
3771{
3772}
3773
3774/*!
3775 \internal
3776*/
3777
3778QStyleHintReturn::~QStyleHintReturn()
3779{
3780
3781}
3782
3783/*!
3784 \class QStyleHintReturnMask
3785 \brief The QStyleHintReturnMask class provides style hints that return a QRegion.
3786
3787 \ingroup appearance
3788 \inmodule QtWidgets
3789*/
3790
3791/*!
3792 \variable QStyleHintReturnMask::region
3793 \brief the region for style hints that return a QRegion
3794*/
3795
3796/*!
3797 Constructs a QStyleHintReturnMask. The member variables are
3798 initialized to default values.
3799*/
3800QStyleHintReturnMask::QStyleHintReturnMask() : QStyleHintReturn(Version, Type)
3801{
3802}
3803
3804/*!
3805 Destructor.
3806*/
3807QStyleHintReturnMask::~QStyleHintReturnMask()
3808{
3809}
3810
3811/*!
3812 \enum QStyleHintReturnMask::StyleOptionType
3813
3814 This enum is used to hold information about the type of the style option, and
3815 is defined for each QStyleHintReturn subclass.
3816
3817 \value Type The type of style option provided (\l{SH_Mask} for
3818 this class).
3819
3820 The type is used internally by QStyleHintReturn, its subclasses, and
3821 qstyleoption_cast() to determine the type of style option. In
3822 general you do not need to worry about this unless you want to
3823 create your own QStyleHintReturn subclass and your own styles.
3824
3825 \sa StyleOptionVersion
3826*/
3827
3828/*!
3829 \enum QStyleHintReturnMask::StyleOptionVersion
3830
3831 This enum is used to hold information about the version of the style option, and
3832 is defined for each QStyleHintReturn subclass.
3833
3834 \value Version 1
3835
3836 The version is used by QStyleHintReturn subclasses to implement
3837 extensions without breaking compatibility. If you use
3838 qstyleoption_cast(), you normally do not need to check it.
3839
3840 \sa StyleOptionType
3841*/
3842
3843/*!
3844 \class QStyleHintReturnVariant
3845 \brief The QStyleHintReturnVariant class provides style hints that return a QVariant.
3846 \since 4.3
3847 \ingroup appearance
3848 \inmodule QtWidgets
3849*/
3850
3851/*!
3852 \variable QStyleHintReturnVariant::variant
3853 \brief the variant for style hints that return a QVariant
3854*/
3855
3856/*!
3857 Constructs a QStyleHintReturnVariant. The member variables are
3858 initialized to default values.
3859*/
3860QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, Type)
3861{
3862}
3863
3864/*!
3865 Destructor.
3866*/
3867QStyleHintReturnVariant::~QStyleHintReturnVariant()
3868{
3869}
3870
3871/*!
3872 \enum QStyleHintReturnVariant::StyleOptionType
3873
3874 This enum is used to hold information about the type of the style option, and
3875 is defined for each QStyleHintReturn subclass.
3876
3877 \value Type The type of style option provided (\l{SH_Variant} for
3878 this class).
3879
3880 The type is used internally by QStyleHintReturn, its subclasses, and
3881 qstyleoption_cast() to determine the type of style option. In
3882 general you do not need to worry about this unless you want to
3883 create your own QStyleHintReturn subclass and your own styles.
3884
3885 \sa StyleOptionVersion
3886*/
3887
3888/*!
3889 \enum QStyleHintReturnVariant::StyleOptionVersion
3890
3891 This enum is used to hold information about the version of the style option, and
3892 is defined for each QStyleHintReturn subclass.
3893
3894 \value Version 1
3895
3896 The version is used by QStyleHintReturn subclasses to implement
3897 extensions without breaking compatibility. If you use
3898 qstyleoption_cast(), you normally do not need to check it.
3899
3900 \sa StyleOptionType
3901*/
3902
3903/*!
3904 \fn template <typename T> T qstyleoption_cast<T>(const QStyleHintReturn *hint)
3905 \relates QStyleHintReturn
3906
3907 Returns a T or \nullptr depending on the \l{QStyleHintReturn::type}{type}
3908 and \l{QStyleHintReturn::version}{version} of \a hint.
3909
3910 Example:
3911
3912 \snippet code/src_gui_styles_qstyleoption.cpp 0
3913
3914 \sa QStyleHintReturn::type, QStyleHintReturn::version
3915*/
3916
3917/*!
3918 \fn template <typename T> T qstyleoption_cast<T>(QStyleHintReturn *hint)
3919 \overload
3920 \relates QStyleHintReturn
3921
3922 Returns a T or \nullptr depending on the type of \a hint.
3923*/
3924
3925#if !defined(QT_NO_DEBUG_STREAM)
3926QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
3927{
3928#if !defined(QT_NO_DEBUG)
3929 switch (optionType) {
3930 case QStyleOption::SO_Default:
3931 debug << "SO_Default"; break;
3932 case QStyleOption::SO_FocusRect:
3933 debug << "SO_FocusRect"; break;
3934 case QStyleOption::SO_Button:
3935 debug << "SO_Button"; break;
3936 case QStyleOption::SO_Tab:
3937 debug << "SO_Tab"; break;
3938 case QStyleOption::SO_MenuItem:
3939 debug << "SO_MenuItem"; break;
3940 case QStyleOption::SO_Frame:
3941 debug << "SO_Frame"; break;
3942 case QStyleOption::SO_ProgressBar:
3943 debug << "SO_ProgressBar"; break;
3944 case QStyleOption::SO_ToolBox:
3945 debug << "SO_ToolBox"; break;
3946 case QStyleOption::SO_Header:
3947 debug << "SO_Header"; break;
3948 case QStyleOption::SO_DockWidget:
3949 debug << "SO_DockWidget"; break;
3950 case QStyleOption::SO_ViewItem:
3951 debug << "SO_ViewItem"; break;
3952 case QStyleOption::SO_TabWidgetFrame:
3953 debug << "SO_TabWidgetFrame"; break;
3954 case QStyleOption::SO_TabBarBase:
3955 debug << "SO_TabBarBase"; break;
3956 case QStyleOption::SO_RubberBand:
3957 debug << "SO_RubberBand"; break;
3958 case QStyleOption::SO_Complex:
3959 debug << "SO_Complex"; break;
3960 case QStyleOption::SO_Slider:
3961 debug << "SO_Slider"; break;
3962 case QStyleOption::SO_SpinBox:
3963 debug << "SO_SpinBox"; break;
3964 case QStyleOption::SO_ToolButton:
3965 debug << "SO_ToolButton"; break;
3966 case QStyleOption::SO_ComboBox:
3967 debug << "SO_ComboBox"; break;
3968 case QStyleOption::SO_TitleBar:
3969 debug << "SO_TitleBar"; break;
3970 case QStyleOption::SO_CustomBase:
3971 debug << "SO_CustomBase"; break;
3972 case QStyleOption::SO_GroupBox:
3973 debug << "SO_GroupBox"; break;
3974 case QStyleOption::SO_ToolBar:
3975 debug << "SO_ToolBar"; break;
3976 case QStyleOption::SO_ComplexCustomBase:
3977 debug << "SO_ComplexCustomBase"; break;
3978 case QStyleOption::SO_SizeGrip:
3979 debug << "SO_SizeGrip"; break;
3980 case QStyleOption::SO_GraphicsItem:
3981 debug << "SO_GraphicsItem"; break;
3982 }
3983#else
3984 Q_UNUSED(optionType);
3985#endif
3986 return debug;
3987}
3988
3989QDebug operator<<(QDebug debug, const QStyleOption &option)
3990{
3991#if !defined(QT_NO_DEBUG)
3992 debug << "QStyleOption(";
3993 debug << QStyleOption::OptionType(option.type);
3994 debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
3995 debug << ',' << option.state;
3996 debug << ',' << option.rect;
3997 debug << ',' << option.styleObject;
3998 debug << ')';
3999#else
4000 Q_UNUSED(option);
4001#endif
4002 return debug;
4003}
4004#endif
4005
4006QT_END_NAMESPACE
4007