Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstyleoption.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSTYLEOPTION_H
5#define QSTYLEOPTION_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qlocale.h>
9#include <QtCore/qvariant.h>
10#if QT_CONFIG(spinbox)
11#include <QtWidgets/qabstractspinbox.h>
12#endif
13#include <QtGui/qicon.h>
14#include <QtGui/qtransform.h>
15#if QT_CONFIG(slider)
16#include <QtWidgets/qslider.h>
17#endif
18#include <QtWidgets/qstyle.h>
19#if QT_CONFIG(tabbar)
20#include <QtWidgets/qtabbar.h>
21#endif
22#if QT_CONFIG(tabwidget)
23#include <QtWidgets/qtabwidget.h>
24#endif
25#if QT_CONFIG(rubberband)
26#include <QtWidgets/qrubberband.h>
27#endif
28#include <QtWidgets/qframe.h>
29#if QT_CONFIG(itemviews)
30# include <QtCore/qabstractitemmodel.h>
31#endif
32
33QT_BEGIN_NAMESPACE
34
35
36class QDebug;
37
38class Q_WIDGETS_EXPORT QStyleOption
39{
40public:
41 enum OptionType {
42 SO_Default, SO_FocusRect, SO_Button, SO_Tab, SO_MenuItem,
43 SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header,
44 SO_DockWidget, SO_ViewItem, SO_TabWidgetFrame,
45 SO_TabBarBase, SO_RubberBand, SO_ToolBar, SO_GraphicsItem,
46
47 SO_Complex = 0xf0000, SO_Slider, SO_SpinBox, SO_ToolButton, SO_ComboBox,
48 SO_TitleBar, SO_GroupBox, SO_SizeGrip,
49
50 SO_CustomBase = 0xf00,
51 SO_ComplexCustomBase = 0xf000000
52 };
53
54 enum StyleOptionType { Type = SO_Default };
55 enum StyleOptionVersion { Version = 1 };
56
57 int version;
58 int type;
59 QStyle::State state;
60 Qt::LayoutDirection direction;
61 QRect rect;
62 QFontMetrics fontMetrics;
63 QPalette palette;
64 QObject *styleObject;
65
66 QStyleOption(int version = QStyleOption::Version, int type = SO_Default);
67 QStyleOption(const QStyleOption &other);
68 ~QStyleOption();
69
70 void initFrom(const QWidget *w);
71 QStyleOption &operator=(const QStyleOption &other);
72};
73
74class Q_WIDGETS_EXPORT QStyleOptionFocusRect : public QStyleOption
75{
76public:
77 enum StyleOptionType { Type = SO_FocusRect };
78 enum StyleOptionVersion { Version = 1 };
79
80 QColor backgroundColor;
81
82 QStyleOptionFocusRect();
83 QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; }
84 QStyleOptionFocusRect &operator=(const QStyleOptionFocusRect &) = default;
85
86protected:
87 QStyleOptionFocusRect(int version);
88};
89
90class Q_WIDGETS_EXPORT QStyleOptionFrame : public QStyleOption
91{
92public:
93 enum StyleOptionType { Type = SO_Frame };
94 enum StyleOptionVersion { Version = 1 };
95
96 int lineWidth;
97 int midLineWidth;
98 enum FrameFeature {
99 None = 0x00,
100 Flat = 0x01,
101 Rounded = 0x02
102 };
103 Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
104 FrameFeatures features;
105 QFrame::Shape frameShape;
106
107 QStyleOptionFrame();
108 QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; }
109 QStyleOptionFrame &operator=(const QStyleOptionFrame &) = default;
110
111protected:
112 QStyleOptionFrame(int version);
113};
114
115Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionFrame::FrameFeatures)
116
117#if QT_CONFIG(tabwidget)
118class Q_WIDGETS_EXPORT QStyleOptionTabWidgetFrame : public QStyleOption
119{
120public:
121 enum StyleOptionType { Type = SO_TabWidgetFrame };
122 enum StyleOptionVersion { Version = 1 };
123
124 int lineWidth;
125 int midLineWidth;
126 QTabBar::Shape shape;
127 QSize tabBarSize;
128 QSize rightCornerWidgetSize;
129 QSize leftCornerWidgetSize;
130 QRect tabBarRect;
131 QRect selectedTabRect;
132
133 QStyleOptionTabWidgetFrame();
134 inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
135 : QStyleOption(Version, Type) { *this = other; }
136 QStyleOptionTabWidgetFrame &operator=(const QStyleOptionTabWidgetFrame &) = default;
137
138protected:
139 QStyleOptionTabWidgetFrame(int version);
140};
141
142#endif // QT_CONFIG(tabwidget)
143
144
145#if QT_CONFIG(tabbar)
146class Q_WIDGETS_EXPORT QStyleOptionTabBarBase : public QStyleOption
147{
148public:
149 enum StyleOptionType { Type = SO_TabBarBase };
150 enum StyleOptionVersion { Version = 1 };
151
152 QTabBar::Shape shape;
153 QRect tabBarRect;
154 QRect selectedTabRect;
155 bool documentMode;
156
157 QStyleOptionTabBarBase();
158 QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; }
159 QStyleOptionTabBarBase &operator=(const QStyleOptionTabBarBase &) = default;
160
161protected:
162 QStyleOptionTabBarBase(int version);
163};
164
165#endif // QT_CONFIG(tabbar)
166
167class Q_WIDGETS_EXPORT QStyleOptionHeader : public QStyleOption
168{
169public:
170 enum StyleOptionType { Type = SO_Header };
171 enum StyleOptionVersion { Version = 1 };
172
173 enum SectionPosition { Beginning, Middle, End, OnlyOneSection };
174 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected,
175 NextAndPreviousAreSelected };
176 enum SortIndicator { None, SortUp, SortDown };
177
178 int section;
179 QString text;
180 Qt::Alignment textAlignment;
181 QIcon icon;
182 Qt::Alignment iconAlignment;
183 SectionPosition position;
184 SelectedPosition selectedPosition;
185 SortIndicator sortIndicator;
186 Qt::Orientation orientation;
187
188 QStyleOptionHeader();
189 QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
190 QStyleOptionHeader &operator=(const QStyleOptionHeader &) = default;
191
192protected:
193 QStyleOptionHeader(int version);
194};
195
196// ### Qt7: merge with QStyleOptionHeader
197class Q_WIDGETS_EXPORT QStyleOptionHeaderV2 : public QStyleOptionHeader
198{
199public:
200 enum StyleOptionType { Type = SO_Header };
201 enum StyleOptionVersion { Version = 2 };
202
203 QStyleOptionHeaderV2();
204 QStyleOptionHeaderV2(const QStyleOptionHeaderV2 &other) : QStyleOptionHeader(Version) { *this = other; }
205 QStyleOptionHeaderV2 &operator=(const QStyleOptionHeaderV2 &) = default;
206
207 Qt::TextElideMode textElideMode:2;
208 bool isSectionDragTarget:1;
209 int unused:29;
210
211protected:
212 QStyleOptionHeaderV2(int version);
213};
214
215class Q_WIDGETS_EXPORT QStyleOptionButton : public QStyleOption
216{
217public:
218 enum StyleOptionType { Type = SO_Button };
219 enum StyleOptionVersion { Version = 1 };
220
221 enum ButtonFeature { None = 0x00, Flat = 0x01, HasMenu = 0x02, DefaultButton = 0x04,
222 AutoDefaultButton = 0x08, CommandLinkButton = 0x10 };
223 Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)
224
225 ButtonFeatures features;
226 QString text;
227 QIcon icon;
228 QSize iconSize;
229
230 QStyleOptionButton();
231 QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; }
232 QStyleOptionButton &operator=(const QStyleOptionButton &) = default;
233
234protected:
235 QStyleOptionButton(int version);
236};
237
238Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionButton::ButtonFeatures)
239
240#if QT_CONFIG(tabbar)
241class Q_WIDGETS_EXPORT QStyleOptionTab : public QStyleOption
242{
243public:
244 enum StyleOptionType { Type = SO_Tab };
245 enum StyleOptionVersion { Version = 1 };
246
247 enum TabPosition { Beginning, Middle, End, OnlyOneTab, Moving };
248 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
249 enum CornerWidget { NoCornerWidgets = 0x00, LeftCornerWidget = 0x01,
250 RightCornerWidget = 0x02 };
251 enum TabFeature { None = 0x00, HasFrame = 0x01, MinimumSizeHint = 0x02 };
252 Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)
253 Q_DECLARE_FLAGS(TabFeatures, TabFeature)
254
255 QTabBar::Shape shape;
256 QString text;
257 QIcon icon;
258 int row;
259 TabPosition position;
260 SelectedPosition selectedPosition;
261 CornerWidgets cornerWidgets;
262 QSize iconSize;
263 bool documentMode;
264 QSize leftButtonSize;
265 QSize rightButtonSize;
266 TabFeatures features;
267 int tabIndex = -1;
268
269 QStyleOptionTab();
270 QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
271 QStyleOptionTab &operator=(const QStyleOptionTab &) = default;
272
273protected:
274 QStyleOptionTab(int version);
275};
276
277Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
278
279#endif // QT_CONFIG(tabbar)
280
281
282#if QT_CONFIG(toolbar)
283
284class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption
285{
286public:
287 enum StyleOptionType { Type = SO_ToolBar };
288 enum StyleOptionVersion { Version = 1 };
289 enum ToolBarPosition { Beginning, Middle, End, OnlyOne };
290 enum ToolBarFeature { None = 0x0, Movable = 0x1 };
291 Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)
292 ToolBarPosition positionOfLine; // The toolbar line position
293 ToolBarPosition positionWithinLine; // The position within a toolbar
294 Qt::ToolBarArea toolBarArea; // The toolbar docking area
295 ToolBarFeatures features;
296 int lineWidth;
297 int midLineWidth;
298 QStyleOptionToolBar();
299 QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
300 QStyleOptionToolBar &operator=(const QStyleOptionToolBar &) = default;
301
302protected:
303 QStyleOptionToolBar(int version);
304};
305
306Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
307
308#endif // QT_CONFIG(toolbar)
309
310class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption
311{
312public:
313 enum StyleOptionType { Type = SO_ProgressBar };
314 enum StyleOptionVersion { Version = 1 };
315
316 int minimum;
317 int maximum;
318 int progress;
319 QString text;
320 Qt::Alignment textAlignment;
321 bool textVisible;
322 bool invertedAppearance;
323 bool bottomToTop;
324
325 QStyleOptionProgressBar();
326 QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
327 QStyleOptionProgressBar &operator=(const QStyleOptionProgressBar &) = default;
328
329protected:
330 QStyleOptionProgressBar(int version);
331};
332
333class Q_WIDGETS_EXPORT QStyleOptionMenuItem : public QStyleOption
334{
335public:
336 enum StyleOptionType { Type = SO_MenuItem };
337 enum StyleOptionVersion { Version = 1 };
338
339 enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, TearOff, Margin,
340 EmptyArea };
341 enum CheckType { NotCheckable, Exclusive, NonExclusive };
342
343 MenuItemType menuItemType;
344 CheckType checkType;
345 bool checked;
346 bool menuHasCheckableItems;
347 QRect menuRect;
348 QString text;
349 QIcon icon;
350 int maxIconWidth;
351 int reservedShortcutWidth;
352 QFont font;
353
354 QStyleOptionMenuItem();
355 QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
356 QStyleOptionMenuItem &operator=(const QStyleOptionMenuItem &) = default;
357
358protected:
359 QStyleOptionMenuItem(int version);
360};
361
362class Q_WIDGETS_EXPORT QStyleOptionDockWidget : public QStyleOption
363{
364public:
365 enum StyleOptionType { Type = SO_DockWidget };
366 enum StyleOptionVersion { Version = 1 };
367
368 QString title;
369 bool closable;
370 bool movable;
371 bool floatable;
372 bool verticalTitleBar;
373
374 QStyleOptionDockWidget();
375 QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
376 QStyleOptionDockWidget &operator=(const QStyleOptionDockWidget &) = default;
377
378protected:
379 QStyleOptionDockWidget(int version);
380};
381
382#if QT_CONFIG(itemviews)
383
384class Q_WIDGETS_EXPORT QStyleOptionViewItem : public QStyleOption
385{
386public:
387 enum StyleOptionType { Type = SO_ViewItem };
388 enum StyleOptionVersion { Version = 1 };
389
390 enum Position { Left, Right, Top, Bottom };
391
392 Qt::Alignment displayAlignment;
393 Qt::Alignment decorationAlignment;
394 Qt::TextElideMode textElideMode;
395 Position decorationPosition;
396 QSize decorationSize;
397 QFont font;
398 bool showDecorationSelected;
399
400 enum ViewItemFeature {
401 None = 0x00,
402 WrapText = 0x01,
403 Alternate = 0x02,
404 HasCheckIndicator = 0x04,
405 HasDisplay = 0x08,
406 HasDecoration = 0x10
407 };
408 Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)
409
410 ViewItemFeatures features;
411
412 QLocale locale;
413 const QWidget *widget;
414
415 enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne };
416
417 QModelIndex index;
418 Qt::CheckState checkState;
419 QIcon icon;
420 QString text;
421 ViewItemPosition viewItemPosition;
422 QBrush backgroundBrush;
423
424 QStyleOptionViewItem();
425 QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
426 QStyleOptionViewItem &operator=(const QStyleOptionViewItem &) = default;
427
428protected:
429 QStyleOptionViewItem(int version);
430};
431
432Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItem::ViewItemFeatures)
433
434#endif // QT_CONFIG(itemviews)
435
436class Q_WIDGETS_EXPORT QStyleOptionToolBox : public QStyleOption
437{
438public:
439 enum StyleOptionType { Type = SO_ToolBox };
440 enum StyleOptionVersion { Version = 1 };
441
442 QString text;
443 QIcon icon;
444
445 enum TabPosition { Beginning, Middle, End, OnlyOneTab };
446 enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
447
448 TabPosition position;
449 SelectedPosition selectedPosition;
450
451 QStyleOptionToolBox();
452 QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
453 QStyleOptionToolBox &operator=(const QStyleOptionToolBox &) = default;
454
455protected:
456 QStyleOptionToolBox(int version);
457};
458
459#if QT_CONFIG(rubberband)
460class Q_WIDGETS_EXPORT QStyleOptionRubberBand : public QStyleOption
461{
462public:
463 enum StyleOptionType { Type = SO_RubberBand };
464 enum StyleOptionVersion { Version = 1 };
465
466 QRubberBand::Shape shape;
467 bool opaque;
468
469 QStyleOptionRubberBand();
470 QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
471 QStyleOptionRubberBand &operator=(const QStyleOptionRubberBand &) = default;
472
473protected:
474 QStyleOptionRubberBand(int version);
475};
476#endif // QT_CONFIG(rubberband)
477
478// -------------------------- Complex style options -------------------------------
479class Q_WIDGETS_EXPORT QStyleOptionComplex : public QStyleOption
480{
481public:
482 enum StyleOptionType { Type = SO_Complex };
483 enum StyleOptionVersion { Version = 1 };
484
485 QStyle::SubControls subControls;
486 QStyle::SubControls activeSubControls;
487
488 QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
489 QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
490 QStyleOptionComplex &operator=(const QStyleOptionComplex &) = default;
491};
492
493#if QT_CONFIG(slider)
494class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex
495{
496public:
497 enum StyleOptionType { Type = SO_Slider };
498 enum StyleOptionVersion { Version = 1 };
499
500 Qt::Orientation orientation;
501 int minimum;
502 int maximum;
503 QSlider::TickPosition tickPosition;
504 int tickInterval;
505 bool upsideDown;
506 int sliderPosition;
507 int sliderValue;
508 int singleStep;
509 int pageStep;
510 qreal notchTarget;
511 bool dialWrapping;
512 Qt::KeyboardModifiers keyboardModifiers;
513
514 QStyleOptionSlider();
515 QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
516 QStyleOptionSlider &operator=(const QStyleOptionSlider &) = default;
517
518protected:
519 QStyleOptionSlider(int version);
520};
521#endif // QT_CONFIG(slider)
522
523#if QT_CONFIG(spinbox)
524class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
525{
526public:
527 enum StyleOptionType { Type = SO_SpinBox };
528 enum StyleOptionVersion { Version = 1 };
529
530 QAbstractSpinBox::ButtonSymbols buttonSymbols;
531 QAbstractSpinBox::StepEnabled stepEnabled;
532 bool frame;
533
534 QStyleOptionSpinBox();
535 QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
536 QStyleOptionSpinBox &operator=(const QStyleOptionSpinBox &) = default;
537
538protected:
539 QStyleOptionSpinBox(int version);
540};
541#endif // QT_CONFIG(spinbox)
542
543class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
544{
545public:
546 enum StyleOptionType { Type = SO_ToolButton };
547 enum StyleOptionVersion { Version = 1 };
548
549 enum ToolButtonFeature { None = 0x00, Arrow = 0x01, Menu = 0x04, MenuButtonPopup = Menu, PopupDelay = 0x08,
550 HasMenu = 0x10 };
551 Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)
552
553 ToolButtonFeatures features;
554 QIcon icon;
555 QSize iconSize;
556 QString text;
557 Qt::ArrowType arrowType;
558 Qt::ToolButtonStyle toolButtonStyle;
559 QPoint pos;
560 QFont font;
561
562 QStyleOptionToolButton();
563 QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
564 QStyleOptionToolButton &operator=(const QStyleOptionToolButton &) = default;
565
566protected:
567 QStyleOptionToolButton(int version);
568};
569
570Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
571
572class Q_WIDGETS_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
573{
574public:
575 enum StyleOptionType { Type = SO_ComboBox };
576 enum StyleOptionVersion { Version = 1 };
577
578 bool editable;
579 QRect popupRect;
580 bool frame;
581 QString currentText;
582 QIcon currentIcon;
583 QSize iconSize;
584 Qt::Alignment textAlignment = Qt::AlignLeft | Qt::AlignVCenter;
585
586 QStyleOptionComboBox();
587 QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
588 QStyleOptionComboBox &operator=(const QStyleOptionComboBox &) = default;
589
590protected:
591 QStyleOptionComboBox(int version);
592};
593
594class Q_WIDGETS_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex
595{
596public:
597 enum StyleOptionType { Type = SO_TitleBar };
598 enum StyleOptionVersion { Version = 1 };
599
600 QString text;
601 QIcon icon;
602 int titleBarState;
603 Qt::WindowFlags titleBarFlags;
604
605 QStyleOptionTitleBar();
606 QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
607 QStyleOptionTitleBar &operator=(const QStyleOptionTitleBar &) = default;
608
609protected:
610 QStyleOptionTitleBar(int version);
611};
612
613class Q_WIDGETS_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex
614{
615public:
616 enum StyleOptionType { Type = SO_GroupBox };
617 enum StyleOptionVersion { Version = 1 };
618
619 QStyleOptionFrame::FrameFeatures features;
620 QString text;
621 Qt::Alignment textAlignment;
622 QColor textColor;
623 int lineWidth;
624 int midLineWidth;
625
626 QStyleOptionGroupBox();
627 QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
628 QStyleOptionGroupBox &operator=(const QStyleOptionGroupBox &) = default;
629protected:
630 QStyleOptionGroupBox(int version);
631};
632
633class Q_WIDGETS_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex
634{
635public:
636 enum StyleOptionType { Type = SO_SizeGrip };
637 enum StyleOptionVersion { Version = 1 };
638
639 Qt::Corner corner;
640
641 QStyleOptionSizeGrip();
642 QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
643 QStyleOptionSizeGrip &operator=(const QStyleOptionSizeGrip &) = default;
644protected:
645 QStyleOptionSizeGrip(int version);
646};
647
648class Q_WIDGETS_EXPORT QStyleOptionGraphicsItem : public QStyleOption
649{
650public:
651 enum StyleOptionType { Type = SO_GraphicsItem };
652 enum StyleOptionVersion { Version = 1 };
653
654 QRectF exposedRect;
655
656 QStyleOptionGraphicsItem();
657 QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
658 QStyleOptionGraphicsItem &operator=(const QStyleOptionGraphicsItem &) = default;
659 static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
660protected:
661 QStyleOptionGraphicsItem(int version);
662};
663
664template <typename T>
665T qstyleoption_cast(const QStyleOption *opt)
666{
667 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
668 if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
669 || int(Opt::Type) == QStyleOption::SO_Default
670 || (int(Opt::Type) == QStyleOption::SO_Complex
671 && opt->type > QStyleOption::SO_Complex)))
672 return static_cast<T>(opt);
673 return nullptr;
674}
675
676template <typename T>
677T qstyleoption_cast(QStyleOption *opt)
678{
679 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
680 if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
681 || int(Opt::Type) == QStyleOption::SO_Default
682 || (int(Opt::Type) == QStyleOption::SO_Complex
683 && opt->type > QStyleOption::SO_Complex)))
684 return static_cast<T>(opt);
685 return nullptr;
686}
687
688// -------------------------- QStyleHintReturn -------------------------------
689class Q_WIDGETS_EXPORT QStyleHintReturn {
690public:
691 enum HintReturnType {
692 SH_Default=0xf000, SH_Mask, SH_Variant
693 };
694
695 enum StyleOptionType { Type = SH_Default };
696 enum StyleOptionVersion { Version = 1 };
697
698 QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default);
699 ~QStyleHintReturn();
700
701 int version;
702 int type;
703};
704
705class Q_WIDGETS_EXPORT QStyleHintReturnMask : public QStyleHintReturn {
706public:
707 enum StyleOptionType { Type = SH_Mask };
708 enum StyleOptionVersion { Version = 1 };
709
710 QStyleHintReturnMask();
711 ~QStyleHintReturnMask();
712
713 QRegion region;
714};
715
716class Q_WIDGETS_EXPORT QStyleHintReturnVariant : public QStyleHintReturn {
717public:
718 enum StyleOptionType { Type = SH_Variant };
719 enum StyleOptionVersion { Version = 1 };
720
721 QStyleHintReturnVariant();
722 ~QStyleHintReturnVariant();
723
724 QVariant variant;
725};
726
727template <typename T>
728T qstyleoption_cast(const QStyleHintReturn *hint)
729{
730 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
731 if (hint && hint->version <= Opt::Version &&
732 (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
733 return static_cast<T>(hint);
734 return nullptr;
735}
736
737template <typename T>
738T qstyleoption_cast(QStyleHintReturn *hint)
739{
740 typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
741 if (hint && hint->version <= Opt::Version &&
742 (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
743 return static_cast<T>(hint);
744 return nullptr;
745}
746
747#if !defined(QT_NO_DEBUG_STREAM)
748Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType);
749Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option);
750#endif
751
752QT_END_NAMESPACE
753
754#endif // QSTYLEOPTION_H
The QApplication class manages the GUI application's control flow and main settings.
QScopedPointer< QImageIOHandlerPrivate > d_ptr
The QPaintEngineState class provides information about the active paint engine's current state....
\inmodule QtGui
virtual QPixmap createPixmap(QSize size)
friend class QPainter
void setSystemRect(const QRect &rect)
void setActive(bool newState)
Sets the active state of the paint engine to state.
virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual QPixmap createPixmapFromImage(QImage image, Qt::ImageConversionFlags flags=Qt::AutoColor)
friend class QWidgetPrivate
QRect systemRect() const
QPaintEngine(PaintEngineFeatures features=PaintEngineFeatures())
Creates a paint engine with the featureset specified by caps.
friend class QFontEngineQPF2
friend class QMacCGContext
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
virtual void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
virtual void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount rectangles in the buffer rects.
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
QPainter * painter() const
Returns the paint engine's painter.
void fix_neg_rect(int *x, int *y, int *w, int *h)
void setPaintDevice(QPaintDevice *device)
virtual QPoint coordinateOffset() const
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
void setDirty(DirtyFlags df)
void setSystemClip(const QRegion &baseClip)
QPaintEngineState * state
friend class QPainterReplayer
friend class QX11GLPlatformPixmap
PaintEngineFeatures gccaps
void clearDirty(DirtyFlags df)
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false.
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
QRegion systemClip() const
bool isExtended() const
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns \nullptr...
bool testDirty(DirtyFlags df)
virtual void updateState(const QPaintEngineState &state)=0
Reimplement this function to update the state of a paint engine.
DirtyFlag
\value DirtyPen The pen is dirty and needs to be updated.
Type
\value X11 \value Windows \value MacPrinter \value CoreGraphics \macos's Quartz2D (CoreGraphics) \val...
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount of the given rectangles using the current pen and brush.
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
friend class QFontEngineMac
Definition qpainter.h:425
friend class QWin32PaintEngine
Definition qpainter.h:430
friend class QWin32PaintEnginePrivate
Definition qpainter.h:431
friend class QWidget
Definition qpainter.h:421
friend class QFontEngineWin
Definition qpainter.h:426
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
bool end()
Ends painting.
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen's color.
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
\inmodule QtGui
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
The QStyleHintReturnMask class provides style hints that return a QRegion.
The QStyleHintReturnVariant class provides style hints that return a QVariant.
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionHeaderV2::textElideMode
\variable QStyleOptionMenuItem::menuItemType
\variable QStyleOptionComplex::subControls
\variable QStyleOption::palette
\variable QStyleOptionFocusRect::backgroundColor
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
\variable QStyleOptionFrame::features
The QStyleOptionHeaderV2 class is used to describe the parameters for drawing a header.
\variable QStyleOptionProgressBar::minimum
\variable QStyleOptionToolBox::selectedPosition
\variable QStyleOptionComboBox::editable
\variable QStyleOptionDockWidget::title
The QStyleOption class stores the parameters used by QStyle functions.
Internal QTextItem.
\inmodule QtGui
uint is_closing
Definition qwidget.h:82
QPalette pal
Definition qwidget.h:91
uint focus_policy
Definition qwidget.h:80
uint in_show
Definition qwidget.h:83
uint unused
Definition qwidget.h:89
uint fstrut_dirty
Definition qwidget.h:85
QRect wrect
Definition qwidget.h:93
QRect crect
Definition qwidget.h:90
uint in_destructor
Definition qwidget.h:88
uint sizehint_forced
Definition qwidget.h:81
uint in_set_window_state
Definition qwidget.h:84
Qt::WindowFlags window_flags
Definition qwidget.h:78
QFont fnt
Definition qwidget.h:92
uint window_modality
Definition qwidget.h:87
uint window_state
Definition qwidget.h:79
WId winid
Definition qwidget.h:76
uint context_menu_policy
Definition qwidget.h:86
uint widget_attributes
Definition qwidget.h:77
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
The QWindows11Style class provides a look and feel suitable for applications on Microsoft Windows 11.
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
void unpolish(QWidget *widget) override
void polish(QWidget *widget) override
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const override
QWindows11Style(QWindows11StylePrivate &dd)
void polish(QPalette &pal) override
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
int styleHint(StyleHint hint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget=nullptr) const override
~QWindows11Style() override
Destructor.
HRGN mask(QWidget *widget)
QWindowsThemeData(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0, const QRect &r=QRect())
QMarginsF margins(const QRect &rect, int propId=TMT_CONTENTMARGINS)
const QWidget * widget
static RECT toRECT(const QRect &qr)
QMarginsF margins(int propId=TMT_CONTENTMARGINS)
static QSizeF themeSize(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0)
HBITMAP buffer(int w=0, int h=0)
static int fixedPixelMetric(QStyle::PixelMetric pm)
static HDC hdcForWidgetBackingStore(const QWidget *widget)
static QBackingStore * backingStoreForWidget(const QWidget *widget)
bool swapAlphaChannel(const QRect &rect, bool allPixels=false)
bool drawBackgroundThruNativeBuffer(QWindowsThemeData &QWindowsThemeData, qreal aditionalDevicePixelRatio, qreal correctionFactor)
static HWND winId(const QWidget *widget)
void init(bool force=false)
static bool isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget)
bool drawBackgroundDirectly(HDC dc, QWindowsThemeData &QWindowsThemeData, qreal aditionalDevicePixelRatio)
static bool isItemViewDelegateLineEdit(const QWidget *widget)
static bool useVista(bool update=false)
bool fixAlphaChannel(const QRect &rect)
void cleanup(bool force=false)
bool isTransparent(QWindowsThemeData &QWindowsThemeData)
bool hasAlphaChannel(const QRect &rect)
QRegion region(QWindowsThemeData &QWindowsThemeData)
bool drawBackground(QWindowsThemeData &QWindowsThemeData, qreal correctionFactor=1)
static HTHEME createTheme(int theme, const QWidget *widget)
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option=nullptr, const QWidget *widget=nullptr)
static QString themeName(int theme)
The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows ...
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override
int styleHint(StyleHint hint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=nullptr) const override
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
void polish(QWidget *widget) override
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=nullptr) const override
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
\reimp
~QWindowsVistaStyle() override
Destructor.
void polish(QPalette &pal) override
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
QWindowsVistaStyle(QWindowsVistaStylePrivate &dd)
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override
void unpolish(QWidget *widget) override
Combined button and popup list for selecting options.
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2439
T qstyleoption_cast(const QStyleOption *opt)
T qstyleoption_cast(QStyleOption *opt)
bool operator==(const ThemeMapKey &k1, const ThemeMapKey &k2)
@ UnknownAlpha
size_t qHash(const ThemeMapKey &key)
AlphaChannelType alphaType
ThemeMapKey(const QWindowsThemeData &data)
ThemeMapKey()=default