Qt 4.8
Public Types | Public Functions | Private Types | Private Functions | Properties | Friends | List of all members
QSizePolicy Class Reference

#include <qsizepolicy.h>

Public Types

enum  ControlType {
  DefaultType = 0x00000001, ButtonBox = 0x00000002, CheckBox = 0x00000004, ComboBox = 0x00000008,
  Frame = 0x00000010, GroupBox = 0x00000020, Label = 0x00000040, Line = 0x00000080,
  LineEdit = 0x00000100, PushButton = 0x00000200, RadioButton = 0x00000400, Slider = 0x00000800,
  SpinBox = 0x00001000, TabWidget = 0x00002000, ToolButton = 0x00004000
}
 
enum  Policy {
  Fixed = 0, Minimum = GrowFlag, Maximum = ShrinkFlag, Preferred = GrowFlag | ShrinkFlag,
  MinimumExpanding = GrowFlag | ExpandFlag, Expanding = GrowFlag | ShrinkFlag | ExpandFlag, Ignored = ShrinkFlag | GrowFlag | IgnoreFlag
}
 
enum  PolicyFlag { GrowFlag = 1, ExpandFlag = 2, ShrinkFlag = 4, IgnoreFlag = 8 }
 

Public Functions

ControlType controlType () const
 
Qt::Orientations expandingDirections () const
 
bool hasHeightForWidth () const
 
bool hasWidthForHeight () const
 
Policy horizontalPolicy () const
 
int horizontalStretch () const
 
 operator QVariant () const
 Returns a QVariant storing this QSizePolicy. More...
 
bool operator!= (const QSizePolicy &s) const
 
bool operator== (const QSizePolicy &s) const
 
 QSizePolicy ()
 
 QSizePolicy (Policy horizontal, Policy vertical)
 
 QSizePolicy (Policy horizontal, Policy vertical, ControlType type)
 
void setControlType (ControlType type)
 
void setHeightForWidth (bool b)
 
void setHorizontalPolicy (Policy d)
 
void setHorizontalStretch (uchar stretchFactor)
 
void setVerticalPolicy (Policy d)
 
void setVerticalStretch (uchar stretchFactor)
 
void setWidthForHeight (bool b)
 
void transpose ()
 
Policy verticalPolicy () const
 
int verticalStretch () const
 

Private Types

enum  SizePolicyMasks {
  HSize = 4, HMask = 0x0f, VMask = HMask << HSize, CTShift = 9,
  CTSize = 5, CTMask = ((0x1 << CTSize) - 1) << CTShift, WFHShift = CTShift + CTSize, UnusedShift = WFHShift + 1,
  UnusedSize = 1
}
 

Private Functions

 QSizePolicy (int i)
 

Properties

quint32 data
 

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QSizePolicy &)
 Writes the size policy to the data stream stream. More...
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QSizePolicy &)
 Reads the size policy from the data stream stream. More...
 

Detailed Description

Definition at line 55 of file qsizepolicy.h.

Enumerations

◆ ControlType

Enumerator
DefaultType 
ButtonBox 
CheckBox 
ComboBox 
Frame 
GroupBox 
Label 
Line 
LineEdit 
PushButton 
RadioButton 
Slider 
SpinBox 
TabWidget 
ToolButton 

Definition at line 91 of file qsizepolicy.h.

91  {
92  DefaultType = 0x00000001,
93  ButtonBox = 0x00000002,
94  CheckBox = 0x00000004,
95  ComboBox = 0x00000008,
96  Frame = 0x00000010,
97  GroupBox = 0x00000020,
98  Label = 0x00000040,
99  Line = 0x00000080,
100  LineEdit = 0x00000100,
101  PushButton = 0x00000200,
102  RadioButton = 0x00000400,
103  Slider = 0x00000800,
104  SpinBox = 0x00001000,
105  TabWidget = 0x00002000,
106  ToolButton = 0x00004000
107  };

◆ Policy

◆ PolicyFlag

Enumerator
GrowFlag 
ExpandFlag 
ShrinkFlag 
IgnoreFlag 

Definition at line 74 of file qsizepolicy.h.

◆ SizePolicyMasks

Enumerator
HSize 
HMask 
VMask 
CTShift 
CTSize 
CTMask 
WFHShift 
UnusedShift 
UnusedSize 

Definition at line 61 of file qsizepolicy.h.

Constructors and Destructors

◆ QSizePolicy() [1/4]

QSizePolicy::QSizePolicy ( )
inline

Definition at line 110 of file qsizepolicy.h.

110 : data(0) { }
quint32 data
Definition: qsizepolicy.h:204

◆ QSizePolicy() [2/4]

QSizePolicy::QSizePolicy ( Policy  horizontal,
Policy  vertical 
)
inline

Definition at line 113 of file qsizepolicy.h.

114  : data(horizontal | (vertical << HSize)) { }
quint32 data
Definition: qsizepolicy.h:204

◆ QSizePolicy() [3/4]

QSizePolicy::QSizePolicy ( Policy  horizontal,
Policy  vertical,
ControlType  type 
)
inline

Definition at line 115 of file qsizepolicy.h.

116  : data(horizontal | (vertical << HSize)) { setControlType(type); }
int type
Definition: qmetatype.cpp:239
quint32 data
Definition: qsizepolicy.h:204
void setControlType(ControlType type)
Definition: qlayout.cpp:1644

◆ QSizePolicy() [4/4]

QSizePolicy::QSizePolicy ( int  i)
inlineprivate

Definition at line 202 of file qsizepolicy.h.

202 : data(i) { }
quint32 data
Definition: qsizepolicy.h:204

Functions

◆ controlType()

QSizePolicy::ControlType QSizePolicy::controlType ( ) const

◆ expandingDirections()

Qt::Orientations QSizePolicy::expandingDirections ( ) const
inline

Definition at line 126 of file qsizepolicy.h.

126  {
127  Qt::Orientations result;
128  if (verticalPolicy() & ExpandFlag)
129  result |= Qt::Vertical;
131  result |= Qt::Horizontal;
132  return result;
133  }
Policy horizontalPolicy() const
Definition: qsizepolicy.h:118
Policy verticalPolicy() const
Definition: qsizepolicy.h:119

◆ hasHeightForWidth()

bool QSizePolicy::hasHeightForWidth ( ) const
inline

Definition at line 136 of file qsizepolicy.h.

Referenced by QTabWidgetPrivate::hasHeightForWidth(), and QScrollAreaPrivate::updateScrollBars().

136 { return data & (1 << 2*HSize); }
quint32 data
Definition: qsizepolicy.h:204

◆ hasWidthForHeight()

bool QSizePolicy::hasWidthForHeight ( ) const
inline

Definition at line 138 of file qsizepolicy.h.

138 { return data & (1 << (WFHShift)); }
quint32 data
Definition: qsizepolicy.h:204

◆ horizontalPolicy()

Policy QSizePolicy::horizontalPolicy ( ) const
inline

◆ horizontalStretch()

int QSizePolicy::horizontalStretch ( ) const
inline

◆ operator QVariant()

QSizePolicy::operator QVariant ( ) const

Returns a QVariant storing this QSizePolicy.

Definition at line 80 of file qlayoutitem.cpp.

81 {
82  return QVariant(QVariant::SizePolicy, this);
83 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92

◆ operator!=()

bool QSizePolicy::operator!= ( const QSizePolicy s) const
inline

Definition at line 141 of file qsizepolicy.h.

141 { return data != s.data; }
quint32 data
Definition: qsizepolicy.h:204

◆ operator==()

bool QSizePolicy::operator== ( const QSizePolicy s) const
inline

Definition at line 140 of file qsizepolicy.h.

140 { return data == s.data; }
quint32 data
Definition: qsizepolicy.h:204

◆ setControlType()

void QSizePolicy::setControlType ( ControlType  type)

Definition at line 1644 of file qlayout.cpp.

1645 {
1646  /*
1647  The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
1648  etc. In memory, we pack it onto the available bits (CTSize) in
1649  setControlType(), and unpack it here.
1650 
1651  Example:
1652 
1653  0x00000001 maps to 0x00000000
1654  0x00000002 maps to 0x00000200
1655  0x00000004 maps to 0x00000400
1656  0x00000008 maps to 0x00000600
1657  etc.
1658  */
1659 
1660  int i = 0;
1661  while (true) {
1662  if (type & (0x1 << i)) {
1663  data = (data & ~CTMask) | (i << CTShift);
1664  return;
1665  }
1666  ++i;
1667  }
1668 }
int type
Definition: qmetatype.cpp:239
quint32 data
Definition: qsizepolicy.h:204

◆ setHeightForWidth()

void QSizePolicy::setHeightForWidth ( bool  b)
inline

Definition at line 135 of file qsizepolicy.h.

Referenced by QCommandLinkButtonPrivate::init(), QLabelPrivate::updateLabel(), and QMessageBoxPrivate::updateSize().

135 { data = b ? (data | (1 << 2*HSize)) : (data & ~(1 << 2*HSize)); }
quint32 data
Definition: qsizepolicy.h:204

◆ setHorizontalPolicy()

void QSizePolicy::setHorizontalPolicy ( Policy  d)
inline

Definition at line 122 of file qsizepolicy.h.

Referenced by QAbstractScrollAreaScrollBarContainer::addWidget().

122 { data = (data & ~HMask) | d; }
double d
Definition: qnumeric_p.h:62
quint32 data
Definition: qsizepolicy.h:204

◆ setHorizontalStretch()

void QSizePolicy::setHorizontalStretch ( uchar  stretchFactor)
inline

Definition at line 146 of file qsizepolicy.h.

Referenced by QSplitterPrivate::findWidget(), and QSplitter::setStretchFactor().

146 { data = (data&0x00ffffff) | (uint(stretchFactor)<<24); }
quint32 data
Definition: qsizepolicy.h:204
unsigned int uint
Definition: qglobal.h:996

◆ setVerticalPolicy()

void QSizePolicy::setVerticalPolicy ( Policy  d)
inline

Definition at line 123 of file qsizepolicy.h.

Referenced by QAbstractScrollAreaScrollBarContainer::addWidget().

123 { data = (data & ~(HMask << HSize)) | (d << HSize); }
double d
Definition: qnumeric_p.h:62
quint32 data
Definition: qsizepolicy.h:204

◆ setVerticalStretch()

void QSizePolicy::setVerticalStretch ( uchar  stretchFactor)
inline

Definition at line 147 of file qsizepolicy.h.

Referenced by QSplitterPrivate::findWidget(), and QSplitter::setStretchFactor().

147 { data = (data&0xff00ffff) | (uint(stretchFactor)<<16); }
quint32 data
Definition: qsizepolicy.h:204
unsigned int uint
Definition: qglobal.h:996

◆ setWidthForHeight()

void QSizePolicy::setWidthForHeight ( bool  b)
inline

Definition at line 137 of file qsizepolicy.h.

137 { data = b ? (data | (1 << (WFHShift))) : (data & ~(1 << (WFHShift))); }
quint32 data
Definition: qsizepolicy.h:204

◆ transpose()

void QSizePolicy::transpose ( )
inline

Definition at line 229 of file qsizepolicy.h.

Referenced by QProgressBarPrivate::init(), QSliderPrivate::init(), QSplitterPrivate::init(), QScrollBarPrivate::init(), QDialogButtonBoxPrivate::initLayout(), QSplitter::setOrientation(), QProgressBar::setOrientation(), and QAbstractSlider::setOrientation().

229  {
230  Policy hData = horizontalPolicy();
231  Policy vData = verticalPolicy();
232  uchar hStretch = uchar(horizontalStretch());
233  uchar vStretch = uchar(verticalStretch());
234  setHorizontalPolicy(vData);
235  setVerticalPolicy(hData);
236  setHorizontalStretch(vStretch);
237  setVerticalStretch(hStretch);
238 }
void setHorizontalStretch(uchar stretchFactor)
Definition: qsizepolicy.h:146
Policy horizontalPolicy() const
Definition: qsizepolicy.h:118
int horizontalStretch() const
Definition: qsizepolicy.h:144
unsigned char uchar
Definition: qglobal.h:994
int verticalStretch() const
Definition: qsizepolicy.h:145
void setHorizontalPolicy(Policy d)
Definition: qsizepolicy.h:122
Policy verticalPolicy() const
Definition: qsizepolicy.h:119
void setVerticalPolicy(Policy d)
Definition: qsizepolicy.h:123
void setVerticalStretch(uchar stretchFactor)
Definition: qsizepolicy.h:147

◆ verticalPolicy()

Policy QSizePolicy::verticalPolicy ( ) const
inline

◆ verticalStretch()

int QSizePolicy::verticalStretch ( ) const
inline

Friends and Related Functions

◆ operator<<

QDataStream & operator<< ( QDataStream stream,
const QSizePolicy policy 
)
friend

Writes the size policy to the data stream stream.

Since
4.2
See also
Format of the QDataStream operators

Definition at line 1687 of file qlayout.cpp.

1688 {
1689  return stream << policy.data;
1690 }
quint32 data
Definition: qsizepolicy.h:204

◆ operator>>

QDataStream & operator>> ( QDataStream stream,
QSizePolicy policy 
)
friend

Reads the size policy from the data stream stream.

Since
4.2
See also
Format of the QDataStream operators

Definition at line 1703 of file qlayout.cpp.

1704 {
1705  return stream >> policy.data;
1706 }
quint32 data
Definition: qsizepolicy.h:204

Properties

◆ data

quint32 QSizePolicy::data
private

Definition at line 204 of file qsizepolicy.h.

Referenced by operator!=(), and operator==().


The documentation for this class was generated from the following files: