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
qlayoutitem.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QLAYOUTITEM_H
5#define QLAYOUTITEM_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qsizepolicy.h>
9#include <QtCore/qrect.h>
10
11#include <limits.h>
12
14
15
16inline constexpr int QLAYOUTSIZE_MAX = INT_MAX/256/16;
17
18class QLayout;
19class QLayoutItem;
20class QSpacerItem;
21class QWidget;
22class QSize;
23
24class Q_WIDGETS_EXPORT QLayoutItem
25{
26public:
27 inline explicit QLayoutItem(Qt::Alignment alignment = Qt::Alignment());
28 virtual ~QLayoutItem();
29 virtual QSize sizeHint() const = 0;
30 virtual QSize minimumSize() const = 0;
31 virtual QSize maximumSize() const = 0;
32 virtual Qt::Orientations expandingDirections() const = 0;
33 virtual void setGeometry(const QRect&) = 0;
34 virtual QRect geometry() const = 0;
35 virtual bool isEmpty() const = 0;
36 virtual bool hasHeightForWidth() const;
37 virtual int heightForWidth(int) const;
38 virtual int minimumHeightForWidth(int) const;
39 virtual void invalidate();
40
41 virtual QWidget *widget() const;
42 virtual QLayout *layout();
43 virtual QSpacerItem *spacerItem();
44
45 Qt::Alignment alignment() const { return align; }
46 void setAlignment(Qt::Alignment a);
47 virtual QSizePolicy::ControlTypes controlTypes() const;
48
49protected:
50 Qt::Alignment align;
51};
52
53inline QLayoutItem::QLayoutItem(Qt::Alignment aalignment)
54 : align(aalignment) { }
55
56class Q_WIDGETS_EXPORT QSpacerItem : public QLayoutItem
57{
58public:
59 QSpacerItem(int w, int h,
60 QSizePolicy::Policy hData = QSizePolicy::Minimum,
61 QSizePolicy::Policy vData = QSizePolicy::Minimum)
62 : width(w), height(h), sizeP(hData, vData) { }
63 ~QSpacerItem();
64
65 void changeSize(int w, int h,
66 QSizePolicy::Policy hData = QSizePolicy::Minimum,
67 QSizePolicy::Policy vData = QSizePolicy::Minimum);
68 QSize sizeHint() const override;
69 QSize minimumSize() const override;
70 QSize maximumSize() const override;
71 Qt::Orientations expandingDirections() const override;
72 bool isEmpty() const override;
73 void setGeometry(const QRect&) override;
74 QRect geometry() const override;
75 QSpacerItem *spacerItem() override;
76 QSizePolicy sizePolicy() const { return sizeP; }
77
78private:
79 int width;
80 int height;
81 QSizePolicy sizeP;
82 QRect rect;
83};
84
85class Q_WIDGETS_EXPORT QWidgetItem : public QLayoutItem
86{
87 Q_DISABLE_COPY(QWidgetItem)
88
89public:
90 explicit QWidgetItem(QWidget *w) : wid(w) { }
91 ~QWidgetItem();
92
93 QSize sizeHint() const override;
94 QSize minimumSize() const override;
95 QSize maximumSize() const override;
96 Qt::Orientations expandingDirections() const override;
97 bool isEmpty() const override;
98 void setGeometry(const QRect&) override;
99 QRect geometry() const override;
100 QWidget *widget() const override;
101
102 bool hasHeightForWidth() const override;
103 int heightForWidth(int) const override;
104 int minimumHeightForWidth(int) const override;
105 QSizePolicy::ControlTypes controlTypes() const override;
106protected:
107 QWidget *wid;
108};
109
110class Q_WIDGETS_EXPORT QWidgetItemV2 : public QWidgetItem
111{
112public:
113 explicit QWidgetItemV2(QWidget *widget);
114 ~QWidgetItemV2();
115
116 QSize sizeHint() const override;
117 QSize minimumSize() const override;
118 QSize maximumSize() const override;
119 int heightForWidth(int width) const override;
120
121private:
122 enum { Dirty = -123, HfwCacheMaxSize = 3 };
123
124 inline bool useSizeCache() const;
125 void updateCacheIfNecessary() const;
126 inline void invalidateSizeCache() {
127 q_cachedMinimumSize.setWidth(Dirty);
128 q_hfwCacheSize = 0;
129 }
130
131 mutable QSize q_cachedMinimumSize;
132 mutable QSize q_cachedSizeHint;
133 mutable QSize q_cachedMaximumSize;
134 mutable QSize q_cachedHfws[HfwCacheMaxSize];
135 mutable short q_firstCachedHfw;
136 mutable short q_hfwCacheSize;
137 void *d;
138
139 friend class QWidgetPrivate;
140
141 Q_DISABLE_COPY(QWidgetItemV2)
142};
143
144QT_END_NAMESPACE
145
146#endif // QLAYOUTITEM_H
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition qboxlayout.h:21
The QHBoxLayout class lines up widgets horizontally.
Definition qboxlayout.h:78
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition qlayoutitem.h:25
friend class QWidget
Definition qpainter.h:421
The QSpacerItem class provides blank space in a layout.
Definition qlayoutitem.h:57
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
QSize minimumSizeHint() const override
\reimp
Definition qwizard.cpp:415
void setSideWidget(QWidget *widget)
Definition qwizard.cpp:421
QWatermarkLabel(QWidget *parent, QWidget *sideWidget)
Definition qwizard.cpp:409
QWidget * sideWidget() const
Definition qwizard.cpp:432
The QWidgetItem class is a layout item that represents a widget.
Definition qlayoutitem.h:86
QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *)
Definition qwizard.cpp:496
QWizardDefaultProperty(const char *className, const char *property, const char *changedSignal)
Definition qwizard.cpp:141
QByteArray changedSignal
Definition qwizard.cpp:138
QString name
Definition qwizard.cpp:158
void resolve(const QList< QWizardDefaultProperty > &defaultPropertyTable)
Definition qwizard.cpp:178
QWizardField(QWizardPage *page, const QString &spec, QObject *object, const char *property, const char *changedSignal)
Definition qwizard.cpp:167
void findProperty(const QWizardDefaultProperty *properties, int propertyCount)
Definition qwizard.cpp:185
QByteArray property
Definition qwizard.cpp:161
QByteArray changedSignal
Definition qwizard.cpp:162
QVariant initialValue
Definition qwizard.cpp:163
QWizardPage * page
Definition qwizard.cpp:157
QObject * object
Definition qwizard.cpp:160
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwizard.cpp:383
QWizardHeader(RulerType, QWidget *parent=nullptr)
Definition qwizard.cpp:251
QWizardHeader(QWidget *parent=nullptr)
Definition qwizard.cpp:273
void setup(const QWizardLayoutInfo &info, const QString &title, const QString &subTitle, const QPixmap &logo, const QPixmap &banner, Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat)
Definition qwizard.cpp:323
bool operator!=(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:221
bool operator==(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:224
TriState completeState
Definition qwizard.cpp:456
void _q_maybeEmitCompleteChanged()
Definition qwizard.cpp:471
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:460
void _q_updateCachedCompleteState()
Definition qwizard.cpp:479
bool cachedIsComplete() const
Definition qwizard.cpp:463
QPixmap pixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:454
QList< QWizardField > pendingFields
Definition qwizard.cpp:455
The QWizardPage class is the base class for wizard pages.
Definition qwizard.h:177
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:563
QList< int > history
Definition qwizard.cpp:552
QMap< QString, int > fieldIndexMap
Definition qwizard.cpp:550
void setStyle(QStyle *style)
Definition qwizard.cpp:1695
PageMap pageMap
Definition qwizard.cpp:548
QGridLayout * mainLayout
Definition qwizard.cpp:595
QList< QWizardDefaultProperty > defaultPropertyTable
Definition qwizard.cpp:551
QAbstractButton * commit
Definition qwizard.cpp:575
bool buttonLayoutContains(QWizard::WizardButton which)
Definition qwizard.cpp:1493
void updateCurrentPage()
Definition qwizard.cpp:1312
void _q_updateButtonStates()
Definition qwizard.cpp:1617
QVBoxLayout * pageVBoxLayout
Definition qwizard.cpp:593
QWatermarkLabel * watermarkLabel
Definition qwizard.cpp:586
QAbstractButton * cancel
Definition qwizard.cpp:577
QWizardLayoutInfo layoutInfoForCurrentPage()
Definition qwizard.cpp:856
bool startSetByUser
Definition qwizard.cpp:554
void connectButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1381
void removeFieldAt(int index)
Definition qwizard.cpp:741
QAbstractButton * next
Definition qwizard.cpp:574
QAbstractButton * help
Definition qwizard.cpp:578
QAbstractButton * back
Definition qwizard.cpp:573
QLabel * subTitleLabel
Definition qwizard.cpp:590
QFrame * pageFrame
Definition qwizard.cpp:588
QLabel * titleLabel
Definition qwizard.cpp:589
void recreateLayout(const QWizardLayoutInfo &info)
Definition qwizard.cpp:917
QWizardAntiFlickerWidget * antiFlickerWidget
Definition qwizard.cpp:582
QAbstractButton * finish
Definition qwizard.cpp:576
QWizardHeader * headerWidget
Definition qwizard.cpp:585
void updateLayout()
Definition qwizard.cpp:1191
QHBoxLayout * buttonLayout
Definition qwizard.cpp:594
void updateMinMaxSizes(const QWizardLayoutInfo &info)
Definition qwizard.cpp:1276
void _q_emitCustomButtonClicked()
Definition qwizard.cpp:1605
void setButtonLayout(const QWizard::WizardButton *array, int size)
Definition qwizard.cpp:1460
bool isVistaThemeEnabled() const
Definition qwizard.cpp:1578
void updatePixmap(QWizard::WizardPixmap which)
Definition qwizard.cpp:1498
QWidget * sideWidget
Definition qwizard.cpp:587
void _q_handleFieldObjectDestroyed(QObject *)
Definition qwizard.cpp:1668
void switchToPage(int newId, Direction direction)
Definition qwizard.cpp:756
QList< QWizard::WizardButton > buttonsCustomLayout
Definition qwizard.cpp:565
void enableUpdates()
Definition qwizard.cpp:1596
int disableUpdatesCount
Definition qwizard.cpp:559
QPixmap defaultPixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:568
QWidget * placeholderWidget2
Definition qwizard.cpp:584
QWizardRuler * bottomRuler
Definition qwizard.cpp:591
Qt::TextFormat subTitleFmt
Definition qwizard.cpp:567
void updateButtonTexts()
Definition qwizard.cpp:1391
void updateButtonLayout()
Definition qwizard.cpp:1420
QList< QWizardField > fields
Definition qwizard.cpp:549
bool ensureButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1352
void updatePalette()
Definition qwizard.cpp:1252
bool buttonsHaveCustomLayout
Definition qwizard.cpp:564
void cleanupPagesNotInHistory()
Definition qwizard.cpp:705
QAbstractButton * btns[QWizard::NButtons]
Definition qwizard.cpp:580
Qt::TextFormat titleFmt
Definition qwizard.cpp:566
void disableUpdates()
Definition qwizard.cpp:1587
QWidget * placeholderWidget1
Definition qwizard.cpp:583
void addField(const QWizardField &field)
Definition qwizard.cpp:719
QWizardLayoutInfo layoutInfo
Definition qwizard.cpp:558
QWizardRuler(QWidget *parent=nullptr)
Definition qwizard.cpp:402
The QWizard class provides a framework for wizards.
Definition qwizard.h:19
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE constexpr int QLAYOUTSIZE_MAX
Definition qlayoutitem.h:16
static const char * buttonSlots(QWizard::WizardButton which)
Definition qwizard.cpp:832
static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
Definition qwizard.cpp:613
static QString object_name_for_button(QWizard::WizardButton which)
Definition qwizard.cpp:1326
Q_DECLARE_TYPEINFO(QWizardDefaultProperty, Q_RELOCATABLE_TYPE)
const int ModernHeaderTopMargin
Definition qwizard.cpp:50
static void changeSpacerSize(QLayout *layout, int index, int width, int height)
Definition qwizard.cpp:58
const int MacLayoutLeftMargin
Definition qwizard.cpp:53
const int GapBetweenLogoAndRightEdge
Definition qwizard.cpp:49
const char property[13]
Definition qwizard.cpp:100
static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, const QByteArray &classY)
Definition qwizard.cpp:84
static QWidget * iWantTheFocus(QWidget *ancestor)
Definition qwizard.cpp:66
Q_DECLARE_TYPEINFO(QWizardField, Q_RELOCATABLE_TYPE)
const int MacLayoutBottomMargin
Definition qwizard.cpp:56
const int MacLayoutRightMargin
Definition qwizard.cpp:55
static const char * changed_signal(int which)
Definition qwizard.cpp:113
const size_t NFallbackDefaultProperties
Definition qwizard.cpp:111
const int ClassicHMargin
Definition qwizard.cpp:51
const int MacButtonTopMargin
Definition qwizard.cpp:52
const char className[16]
[1]
Definition qwizard.cpp:99
QT_REQUIRE_CONFIG(wizard)