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
qsizepolicy.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 "qsizepolicy.h"
5
6#include <qdatastream.h>
7#include <qdebug.h>
8#include <qvariant.h>
9
11
200{
201 return QSizePolicy::ControlType(1 << bits.ctype);
202}
203
204
221{
222 bits.ctype = toControlTypeFieldValue(type);
223}
224
403QSizePolicy::operator QVariant() const
404{
405 return QVariant::fromValue(*this);
406}
407
408#ifndef QT_NO_DATASTREAM
409
419{
420 // The order here is for historical reasons. (compatibility with Qt4)
421 quint32 data = (policy.bits.horPolicy | // [0, 3]
422 policy.bits.verPolicy << 4 | // [4, 7]
423 policy.bits.hfw << 8 | // [8]
424 policy.bits.ctype << 9 | // [9, 13]
425 policy.bits.wfh << 14 | // [14]
426 policy.bits.retainSizeWhenHidden << 15 | // [15]
427 policy.bits.verStretch << 16 | // [16, 23]
428 policy.bits.horStretch << 24); // [24, 31]
429 return stream << data;
430}
431
432#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1))
433
443{
445 stream >> data;
446 policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4);
447 policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4);
448 policy.bits.hfw = VALUE_OF_BITS(data, 8, 1);
449 policy.bits.ctype = VALUE_OF_BITS(data, 9, 5);
450 policy.bits.wfh = VALUE_OF_BITS(data, 14, 1);
451 policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1);
452 policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8);
453 policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8);
454 return stream;
455}
456#endif // QT_NO_DATASTREAM
457
458#ifndef QT_NO_DEBUG_STREAM
460{
461 QDebugStateSaver saver(dbg);
462 dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy()
463 << ", verticalPolicy = " << p.verticalPolicy() << ')';
464 return dbg;
465}
466#endif
467
469
470#include "moc_qsizepolicy.cpp"
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtCore
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
void setControlType(ControlType type) noexcept
ControlType controlType() const noexcept
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
Combined button and popup list for selecting options.
EGLStreamKHR stream
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]
QDebug operator<<(QDebug dbg, const QSizePolicy &p)
#define VALUE_OF_BITS(data, bitstart, bitcount)
unsigned int quint32
Definition qtypes.h:50
QDataStream & operator>>(QDataStream &in, MyClass &myObj)
QSizePolicy policy