Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qlayoutpolicy.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qlayoutpolicy_p.h"
5#include <QtCore/qdebug.h>
6#include <QtCore/qdatastream.h>
7
9
11{
12 /*
13 The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
14 etc. In memory, we pack it onto the available bits (CTSize) in
15 setControlType(), and unpack it here.
16
17 Example:
18
19 0x00000001 maps to 0
20 0x00000002 maps to 1
21 0x00000004 maps to 2
22 0x00000008 maps to 3
23 etc.
24 */
25
26 int i = 0;
27 while (true) {
28 if (type & (0x1 << i)) {
29 bits.ctype = i;
30 return;
31 }
32 ++i;
33 }
34}
35
40
41#ifndef QT_NO_DATASTREAM
42
51{
52 // The order here is for historical reasons. (compatibility with Qt4)
53 quint32 data = (policy.bits.horPolicy | // [0, 3]
54 policy.bits.verPolicy << 4 | // [4, 7]
55 policy.bits.hfw << 8 | // [8]
56 policy.bits.ctype << 9 | // [9, 13]
57 policy.bits.wfh << 14 | // [14]
58 //policy.bits.padding << 15 | // [15]
59 policy.bits.verStretch << 16 | // [16, 23]
60 policy.bits.horStretch << 24); // [24, 31]
61 return stream << data;
62}
63
64#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1))
65
74{
76 stream >> data;
77 policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4);
78 policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4);
79 policy.bits.hfw = VALUE_OF_BITS(data, 8, 1);
80 policy.bits.ctype = VALUE_OF_BITS(data, 9, 5);
81 policy.bits.wfh = VALUE_OF_BITS(data, 14, 1);
82 policy.bits.padding = 0;
83 policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8);
84 policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8);
85 return stream;
86}
87#endif // QT_NO_DATASTREAM
88
89#ifndef QT_NO_DEBUG_STREAM
91{
92 QDebugStateSaver saver(dbg);
93 dbg.nospace() << "QLayoutPolicy(horizontalPolicy = " << p.horizontalPolicy()
94 << ", verticalPolicy = " << p.verticalPolicy() << ')';
95 return dbg;
96}
97#endif
98
100
101#include "moc_qlayoutpolicy_p.cpp"
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtCore
Q_GUI_EXPORT ControlType controlType() const
Q_GUI_EXPORT void setControlType(ControlType type)
Combined button and popup list for selecting options.
EGLStreamKHR stream
QDebug operator<<(QDebug dbg, const QLayoutPolicy &p)
#define VALUE_OF_BITS(data, bitstart, bitcount)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLfloat GLfloat p
[1]
unsigned int quint32
Definition qtypes.h:50
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QSizePolicy policy