Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qlayoutpolicy_p.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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QLAYOUTPOLICY_H
6
#
define
QLAYOUTPOLICY_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtGui
/
private
/
qtguiglobal_p
.
h
>
20
#
include
<
QtCore
/
qobject
.
h
>
21
#
include
<
QtCore
/
qnamespace
.
h
>
22
23
#
ifndef
QT_NO_DATASTREAM
24
#
include
<
QtCore
/
qdatastream
.
h
>
25
#
endif
26
27
QT_BEGIN_NAMESPACE
28
29
30
class
QVariant;
31
32
class
QLayoutPolicy
33
{
34
Q_GADGET_EXPORT(Q_GUI_EXPORT)
35
36
public
:
37
enum
PolicyFlag
{
38
GrowFlag
= 1,
39
ExpandFlag
= 2,
40
ShrinkFlag
= 4,
41
IgnoreFlag
= 8
42
};
43
Q_DECLARE_FLAGS(Policy, PolicyFlag)
44
Q_FLAG
(
Policy
)
45
46
static
constexpr
inline
Policy
Fixed
= {};
47
static
constexpr
inline
Policy
Minimum
=
GrowFlag
;
48
static
constexpr
inline
Policy
Maximum
=
ShrinkFlag
;
49
static
constexpr
inline
Policy
Preferred
= Minimum | Maximum;
50
static
constexpr
inline
Policy
MinimumExpanding
= Minimum | ExpandFlag;
51
static
constexpr
inline
Policy
Expanding
= Preferred | ExpandFlag;
52
static
constexpr
inline
Policy
Ignored
= Preferred | IgnoreFlag;
53
54
enum
ControlType
{
55
DefaultType
= 0x00000001,
56
ButtonBox
= 0x00000002,
57
CheckBox
= 0x00000004,
58
ComboBox
= 0x00000008,
59
Frame
= 0x00000010,
60
GroupBox
= 0x00000020,
61
Label
= 0x00000040,
62
Line
= 0x00000080,
63
LineEdit
= 0x00000100,
64
PushButton
= 0x00000200,
65
RadioButton
= 0x00000400,
66
Slider
= 0x00000800,
67
SpinBox
= 0x00001000,
68
TabWidget
= 0x00002000,
69
ToolButton
= 0x00004000
70
};
71
Q_DECLARE_FLAGS(ControlTypes,
ControlType
)
72
73
QLayoutPolicy
() :
data
(0) { }
74
75
QLayoutPolicy
(
Policy
horizontal
,
Policy
vertical
,
ControlType
type
=
DefaultType
)
76
:
data
(0) {
77
bits
.
horPolicy
=
horizontal
;
78
bits
.
verPolicy
=
vertical
;
79
setControlType
(
type
);
80
}
81
Policy
horizontalPolicy
()
const
{
return
static_cast
<
Policy
>(
bits
.
horPolicy
); }
82
Policy
verticalPolicy
()
const
{
return
static_cast
<
Policy
>(
bits
.
verPolicy
); }
83
Q_GUI_EXPORT
ControlType
controlType
()
const
;
84
85
void
setHorizontalPolicy
(Policy d) { bits.horPolicy = d; }
86
void
setVerticalPolicy
(Policy d) { bits.verPolicy = d; }
87
Q_GUI_EXPORT
void
setControlType
(
ControlType
type);
88
89
Qt
::
Orientations
expandingDirections
()
const
{
90
Qt::Orientations result;
91
if
(verticalPolicy() & ExpandFlag)
92
result |= Qt::Vertical;
93
if
(horizontalPolicy() & ExpandFlag)
94
result |= Qt::Horizontal;
95
return
result;
96
}
97
98
void
setHeightForWidth
(
bool
b) { bits.hfw = b; }
99
bool
hasHeightForWidth
()
const
{
return
bits.hfw; }
100
void
setWidthForHeight
(
bool
b) { bits.wfh = b; }
101
bool
hasWidthForHeight
()
const
{
return
bits.wfh; }
102
103
bool
operator
==(
const
QLayoutPolicy
& s)
const
{
return
data == s.data; }
104
bool
operator
!=(
const
QLayoutPolicy
& s)
const
{
return
data != s.data; }
105
106
int
horizontalStretch
()
const
{
return
static_cast
<
int
>(bits.horStretch); }
107
int
verticalStretch
()
const
{
return
static_cast
<
int
>(bits.verStretch); }
108
void
setHorizontalStretch
(
int
stretchFactor) { bits.horStretch =
static_cast
<quint32>(qBound(0, stretchFactor, 255)); }
109
void
setVerticalStretch
(
int
stretchFactor) { bits.verStretch =
static_cast
<quint32>(qBound(0, stretchFactor, 255)); }
110
111
inline
void
transpose
();
112
113
114
private
:
115
#
ifndef
QT_NO_DATASTREAM
116
friend
QDataStream
&
operator
<<(QDataStream &,
const
QLayoutPolicy
&);
117
friend
QDataStream
&
operator
>>(QDataStream &,
QLayoutPolicy
&);
118
#
endif
119
QLayoutPolicy(
int
i) : data(i) { }
120
121
union
{
122
struct
{
123
quint32 horStretch : 8;
124
quint32 verStretch : 8;
125
quint32 horPolicy : 4;
126
quint32 verPolicy : 4;
127
quint32 ctype : 5;
128
quint32 hfw : 1;
129
quint32 wfh : 1;
130
quint32 padding : 1;
// feel free to use
131
} bits;
132
quint32 data;
133
};
134
};
135
136
Q_DECLARE_OPERATORS_FOR_FLAGS(
QLayoutPolicy
::Policy)
137
Q_DECLARE_OPERATORS_FOR_FLAGS(QLayoutPolicy::ControlTypes)
138
139
#
ifndef
QT_NO_DATASTREAM
140
QDataStream &operator<<(QDataStream &,
const
QLayoutPolicy &);
141
QDataStream
&
operator
>>(QDataStream &,
QLayoutPolicy
&);
142
#
endif
143
144
#
ifndef
QT_NO_DEBUG_STREAM
145
QDebug
operator
<<(QDebug dbg,
const
QLayoutPolicy
&);
146
#
endif
147
148
inline
void
QLayoutPolicy
::
transpose
() {
149
Policy hData = horizontalPolicy();
150
Policy vData = verticalPolicy();
151
int
hStretch =
horizontalStretch
(
)
;
152
int
vStretch =
verticalStretch
(
)
;
153
setHorizontalPolicy(vData);
154
setVerticalPolicy(hData);
155
setHorizontalStretch
(
vStretch
)
;
156
setVerticalStretch
(
hStretch
)
;
157
}
158
159
QT_END_NAMESPACE
160
161
#
endif
// QLAYOUTPOLICY_H
QAbstractLayoutStyleInfo
Definition
qabstractlayoutstyleinfo_p.h:26
QLayoutPolicy
\inmodule QtGui
Definition
qlayoutpolicy_p.h:33
QLayoutPolicy::operator>>
friend QDataStream & operator>>(QDataStream &, QLayoutPolicy &)
Reads the size policy from the data stream stream.
Definition
qlayoutpolicy.cpp:71
QLayoutPolicy::Minimum
static constexpr Policy Minimum
Definition
qlayoutpolicy_p.h:47
QLayoutPolicy::Maximum
static constexpr Policy Maximum
Definition
qlayoutpolicy_p.h:48
QLayoutPolicy::verticalStretch
int verticalStretch() const
Definition
qlayoutpolicy_p.h:107
QLayoutPolicy::Ignored
static constexpr Policy Ignored
Definition
qlayoutpolicy_p.h:52
QLayoutPolicy::operator!=
bool operator!=(const QLayoutPolicy &s) const
Definition
qlayoutpolicy_p.h:104
QLayoutPolicy::operator<<
friend QDataStream & operator<<(QDataStream &, const QLayoutPolicy &)
Writes the size policy to the data stream stream.
Definition
qlayoutpolicy.cpp:48
QLayoutPolicy::hasHeightForWidth
bool hasHeightForWidth() const
Definition
qlayoutpolicy_p.h:99
QLayoutPolicy::Expanding
static constexpr Policy Expanding
Definition
qlayoutpolicy_p.h:51
QLayoutPolicy::Preferred
static constexpr Policy Preferred
Definition
qlayoutpolicy_p.h:49
QLayoutPolicy::horizontalStretch
int horizontalStretch() const
Definition
qlayoutpolicy_p.h:106
QLayoutPolicy::setHorizontalStretch
void setHorizontalStretch(int stretchFactor)
Definition
qlayoutpolicy_p.h:108
QLayoutPolicy::setHorizontalPolicy
void setHorizontalPolicy(Policy d)
Definition
qlayoutpolicy_p.h:85
QLayoutPolicy::hasWidthForHeight
bool hasWidthForHeight() const
Definition
qlayoutpolicy_p.h:101
QLayoutPolicy::setVerticalPolicy
void setVerticalPolicy(Policy d)
Definition
qlayoutpolicy_p.h:86
QLayoutPolicy::MinimumExpanding
static constexpr Policy MinimumExpanding
Definition
qlayoutpolicy_p.h:50
QLayoutPolicy::setVerticalStretch
void setVerticalStretch(int stretchFactor)
Definition
qlayoutpolicy_p.h:109
QLayoutPolicy::ControlType
ControlType
Definition
qlayoutpolicy_p.h:54
QLayoutPolicy::ToolButton
@ ToolButton
Definition
qlayoutpolicy_p.h:69
QLayoutPolicy::Frame
@ Frame
Definition
qlayoutpolicy_p.h:59
QLayoutPolicy::SpinBox
@ SpinBox
Definition
qlayoutpolicy_p.h:67
QLayoutPolicy::Slider
@ Slider
Definition
qlayoutpolicy_p.h:66
QLayoutPolicy::Line
@ Line
Definition
qlayoutpolicy_p.h:62
QLayoutPolicy::GroupBox
@ GroupBox
Definition
qlayoutpolicy_p.h:60
QLayoutPolicy::Label
@ Label
Definition
qlayoutpolicy_p.h:61
QLayoutPolicy::TabWidget
@ TabWidget
Definition
qlayoutpolicy_p.h:68
QLayoutPolicy::PushButton
@ PushButton
Definition
qlayoutpolicy_p.h:64
QLayoutPolicy::CheckBox
@ CheckBox
Definition
qlayoutpolicy_p.h:57
QLayoutPolicy::ComboBox
@ ComboBox
Definition
qlayoutpolicy_p.h:58
QLayoutPolicy::ButtonBox
@ ButtonBox
Definition
qlayoutpolicy_p.h:56
QLayoutPolicy::RadioButton
@ RadioButton
Definition
qlayoutpolicy_p.h:65
QLayoutPolicy::LineEdit
@ LineEdit
Definition
qlayoutpolicy_p.h:63
QLayoutPolicy::DefaultType
@ DefaultType
Definition
qlayoutpolicy_p.h:55
QLayoutPolicy::operator==
bool operator==(const QLayoutPolicy &s) const
Definition
qlayoutpolicy_p.h:103
QLayoutPolicy::setHeightForWidth
void setHeightForWidth(bool b)
Definition
qlayoutpolicy_p.h:98
QLayoutPolicy::transpose
void transpose()
Definition
qlayoutpolicy_p.h:148
QLayoutPolicy::setWidthForHeight
void setWidthForHeight(bool b)
Definition
qlayoutpolicy_p.h:100
QLayoutPolicy::expandingDirections
Qt::Orientations expandingDirections() const
Definition
qlayoutpolicy_p.h:89
QLayoutPolicy::setControlType
Q_GUI_EXPORT void setControlType(ControlType type)
Definition
qlayoutpolicy.cpp:16
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
operator<<
QDebug operator<<(QDebug dbg, const QLayoutPolicy &p)
Definition
qlayoutpolicy.cpp:88
qtbase
src
gui
util
qlayoutpolicy_p.h
Generated on
for Qt by
1.18.0