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

The QFormLayout class manages forms of input widgets and their associated labels. More...

#include <qformlayout.h>

Inheritance diagram for QFormLayout:
QLayout QObject QLayoutItem

Public Types

enum  FieldGrowthPolicy { FieldsStayAtSizeHint, ExpandingFieldsGrow, AllNonFixedFieldsGrow }
 This enum specifies the different policies that can be used to control the way in which the form's fields grow. More...
 
enum  ItemRole { LabelRole = 0, FieldRole = 1, SpanningRole = 2 }
 This enum specifies the types of widgets (or other layout items) that may appear in a row. More...
 
enum  RowWrapPolicy { DontWrapRows, WrapLongRows, WrapAllRows }
 This enum specifies the different policies that can be used to control the way in which the form's rows wrap. More...
 
- Public Types inherited from QLayout
enum  SizeConstraint {
  SetDefaultConstraint, SetNoConstraint, SetMinimumSize, SetFixedSize,
  SetMaximumSize, SetMinAndMaxSize
}
 The possible values are: More...
 

Public Functions

void addItem (QLayoutItem *item)
 Reimplemented Function More...
 
void addRow (QWidget *label, QWidget *field)
 Adds a new row to the bottom of this form layout, with the given label and field. More...
 
void addRow (QWidget *label, QLayout *field)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void addRow (const QString &labelText, QWidget *field)
 This overload automatically creates a QLabel behind the scenes with labelText as its text. More...
 
void addRow (const QString &labelText, QLayout *field)
 This overload automatically creates a QLabel behind the scenes with labelText as its text. More...
 
void addRow (QWidget *widget)
 Adds the specified widget at the end of this form layout. More...
 
void addRow (QLayout *layout)
 Adds the specified layout at the end of this form layout. More...
 
int count () const
 Reimplemented Function More...
 
Qt::Orientations expandingDirections () const
 Reimplemented Function More...
 
FieldGrowthPolicy fieldGrowthPolicy () const
 
Qt::Alignment formAlignment () const
 
void getItemPosition (int index, int *rowPtr, ItemRole *rolePtr) const
 Retrieves the row and role (column) of the item at the specified index. More...
 
void getLayoutPosition (QLayout *layout, int *rowPtr, ItemRole *rolePtr) const
 Retrieves the row and role (column) of the specified child layout. More...
 
void getWidgetPosition (QWidget *widget, int *rowPtr, ItemRole *rolePtr) const
 Retrieves the row and role (column) of the specified widget in the layout. More...
 
bool hasHeightForWidth () const
 Reimplemented Function More...
 
int heightForWidth (int width) const
 Reimplemented Function More...
 
int horizontalSpacing () const
 
void insertRow (int row, QWidget *label, QWidget *field)
 Inserts a new row at position row in this form layout, with the given label and field. More...
 
void insertRow (int row, QWidget *label, QLayout *field)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void insertRow (int row, const QString &labelText, QWidget *field)
 This overload automatically creates a QLabel behind the scenes with labelText as its text. More...
 
void insertRow (int row, const QString &labelText, QLayout *field)
 This overload automatically creates a QLabel behind the scenes with labelText as its text. More...
 
void insertRow (int row, QWidget *widget)
 Inserts the specified widget at position row in this form layout. More...
 
void insertRow (int row, QLayout *layout)
 Inserts the specified layout at position row in this form layout. More...
 
void invalidate ()
 Reimplemented Function More...
 
QLayoutItemitemAt (int row, ItemRole role) const
 Returns the layout item in the given row with the specified role (column). More...
 
QLayoutItemitemAt (int index) const
 Reimplemented Function More...
 
Qt::Alignment labelAlignment () const
 
QWidgetlabelForField (QWidget *field) const
 Returns the label associated with the given field. More...
 
QWidgetlabelForField (QLayout *field) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QSize minimumSize () const
 Reimplemented Function More...
 
 QFormLayout (QWidget *parent=0)
 Constructs a new form layout with the given parent widget. More...
 
int rowCount () const
 Returns the number of rows in the form. More...
 
RowWrapPolicy rowWrapPolicy () const
 
void setFieldGrowthPolicy (FieldGrowthPolicy policy)
 
void setFormAlignment (Qt::Alignment alignment)
 
void setGeometry (const QRect &rect)
 Reimplemented Function More...
 
void setHorizontalSpacing (int spacing)
 
void setItem (int row, ItemRole role, QLayoutItem *item)
 Sets the item in the given row for the given role to item, extending the layout with empty rows if necessary. More...
 
void setLabelAlignment (Qt::Alignment alignment)
 
void setLayout (int row, ItemRole role, QLayout *layout)
 Sets the sub-layout in the given row for the given role to layout, extending the form layout with empty rows if necessary. More...
 
void setRowWrapPolicy (RowWrapPolicy policy)
 
void setSpacing (int)
 This function sets both the vertical and horizontal spacing to spacing. More...
 
void setVerticalSpacing (int spacing)
 
void setWidget (int row, ItemRole role, QWidget *widget)
 Sets the widget in the given row for the given role to widget, extending the layout with empty rows if necessary. More...
 
QSize sizeHint () const
 Reimplemented Function More...
 
int spacing () const
 If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it returns -1. More...
 
QLayoutItemtakeAt (int index)
 Reimplemented Function More...
 
int verticalSpacing () const
 
 ~QFormLayout ()
 Destroys the form layout. More...
 
- Public Functions inherited from QLayout
bool activate ()
 Redoes the layout for parentWidget() if necessary. More...
 
void addWidget (QWidget *w)
 Adds widget w to this layout in a manner specific to the layout. More...
 
QMargins contentsMargins () const
 Returns the margins used around the layout. More...
 
QRect contentsRect () const
 Returns the layout's geometry() rectangle, but taking into account the contents margins. More...
 
Qt::Orientations expandingDirections () const
 Returns whether this layout can make use of more space than sizeHint(). More...
 
QRect geometry () const
 Reimplemented Function More...
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
virtual int indexOf (QWidget *) const
 Searches for widget widget in this layout (not including child layouts). More...
 
void invalidate ()
 Reimplemented Function More...
 
bool isEmpty () const
 Reimplemented Function More...
 
bool isEnabled () const
 Returns true if the layout is enabled; otherwise returns false. More...
 
QLayoutlayout ()
 Reimplemented Function More...
 
int margin () const
 
QSize maximumSize () const
 Returns the maximum size of this layout. More...
 
QWidgetmenuBar () const
 Returns the menu bar set for this layout, or 0 if no menu bar is set. More...
 
QSize minimumSize () const
 Returns the minimum size of this layout. More...
 
QWidgetparentWidget () const
 Returns the parent widget of this layout, or 0 if this layout is not installed on any widget. More...
 
 QLayout (QWidget *parent)
 Constructs a new top-level QLayout, with parent parent. More...
 
 QLayout ()
 Constructs a new child QLayout. More...
 
void removeItem (QLayoutItem *)
 Removes the layout item item from the layout. More...
 
void removeWidget (QWidget *w)
 Removes the widget widget from the layout. More...
 
bool setAlignment (QWidget *w, Qt::Alignment alignment)
 Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false. More...
 
bool setAlignment (QLayout *l, Qt::Alignment alignment)
 Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false. More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the left, top, right, and bottom margins to use around the layout. More...
 
void setContentsMargins (const QMargins &margins)
 Sets the margins to use around the layout. More...
 
void setEnabled (bool)
 Enables this layout if enable is true, otherwise disables it. More...
 
void setMargin (int)
 
void setMenuBar (QWidget *w)
 Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). More...
 
void setSizeConstraint (SizeConstraint)
 
void setSpacing (int)
 
SizeConstraint sizeConstraint () const
 
int spacing () const
 
int totalHeightForWidth (int w) const
 Also takes contentsMargins and menu bar into account. More...
 
QSize totalMaximumSize () const
 Also takes contentsMargins and menu bar into account. More...
 
QSize totalMinimumSize () const
 Also takes contentsMargins and menu bar into account. More...
 
QSize totalSizeHint () const
 Also takes contentsMargins and menu bar into account. More...
 
void update ()
 Updates the layout for parentWidget(). More...
 
 ~QLayout ()
 Destroys the layout, deleting all child layouts. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QLayoutItem
Qt::Alignment alignment () const
 Returns the alignment of this item. More...
 
QSizePolicy::ControlTypes controlTypes () const
 Returns the control type(s) for the layout item. More...
 
virtual int minimumHeightForWidth (int) const
 Returns the minimum height this widget needs for the given width, w. More...
 
 QLayoutItem (Qt::Alignment alignment=0)
 Constructs a layout item with an alignment. More...
 
void setAlignment (Qt::Alignment a)
 Sets the alignment of this item to alignment. More...
 
virtual QSpacerItemspacerItem ()
 If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned. More...
 
virtual QWidgetwidget ()
 If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned. More...
 
virtual ~QLayoutItem ()
 Destroys the QLayoutItem. More...
 

Private Functions

void resetFieldGrowthPolicy ()
 
void resetFormAlignment ()
 
void resetLabelAlignment ()
 
void resetRowWrapPolicy ()
 

Properties

FieldGrowthPolicy fieldGrowthPolicy
 the way in which the form's fields grow More...
 
Qt::Alignment formAlignment
 the alignment of the form layout's contents within the layout's geometry More...
 
int horizontalSpacing
 the spacing between widgets that are laid out side by side More...
 
Qt::Alignment labelAlignment
 the horizontal alignment of the labels More...
 
RowWrapPolicy rowWrapPolicy
 the way in which the form's rows wrap More...
 
int verticalSpacing
 the spacing between widgets that are laid out vertically More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QLayout
static QSize closestAcceptableSize (const QWidget *w, const QSize &s)
 Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is as close as possible to size. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QLayout
void addChildLayout (QLayout *l)
 This function is called from addLayout() or insertLayout() functions in subclasses to add layout l as a sub-layout. More...
 
void addChildWidget (QWidget *w)
 This function is called from addWidget() functions in subclasses to add w as a managed widget of a layout. More...
 
bool adoptLayout (QLayout *layout)
 
QRect alignmentRect (const QRect &) const
 Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment(). More...
 
void childEvent (QChildEvent *e)
 Reimplemented Function More...
 
 QLayout (QLayoutPrivate &d, QLayout *, QWidget *)
 
void widgetEvent (QEvent *)
 Performs child widget layout when the parent widget is resized. More...
 
- Protected Functions inherited from QObject
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QLayoutItem
Qt::Alignment align
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QFormLayout class manages forms of input widgets and their associated labels.

Since
4.4

QFormLayout is a convenience layout class that lays out its children in a two-column form. The left column consists of labels and the right column consists of "field" widgets (line editors, spin boxes, etc.).

Traditionally, such two-column form layouts were achieved using QGridLayout. QFormLayout is a higher-level alternative that provides the following advantages:

The table below shows the default appearance in different styles.

QCommonStyle derived styles (except QPlastiqueStyle) QMacStyle QPlastiqueStyle Qt Extended styles
qformlayout-win.png
qformlayout-mac.png
qformlayout-kde.png
qformlayout-qpe.png
Traditional style used for Windows, GNOME, and earlier versions of KDE. Labels are left aligned, and expanding fields grow to fill the available space. (This normally corresponds to what we would get using a two-column QGridLayout.) Style based on the Mac OS X Aqua guidelines. Labels are right-aligned, the fields don't grow beyond their size hint, and the form is horizontally centered. Recommended style for KDE applications. Similar to MacStyle, except that the form is left-aligned and all fields grow to fill the available space. Default style for Qt Extended styles. Labels are right-aligned, expanding fields grow to fill the available space, and row wrapping is enabled for long lines.

The form styles can be also be overridden individually by calling setLabelAlignment(), setFormAlignment(), setFieldGrowthPolicy(), and setRowWrapPolicy(). For example, to simulate the form layout appearance of QMacStyle on all platforms, but with left-aligned labels, you could write:

See also
QGridLayout, QBoxLayout, QStackedLayout

Definition at line 55 of file qformlayout.h.

Enumerations

◆ FieldGrowthPolicy

This enum specifies the different policies that can be used to control the way in which the form's fields grow.

  • AllNonFixedFieldsGrow All fields with a size policy that allows them to grow will grow to fill the available space. This is the default policy for most styles.
See also
fieldGrowthPolicy
Enumerator
FieldsStayAtSizeHint 
ExpandingFieldsGrow 
AllNonFixedFieldsGrow 

Definition at line 68 of file qformlayout.h.

◆ ItemRole

This enum specifies the types of widgets (or other layout items) that may appear in a row.

  • LabelRole A label widget.
  • FieldRole A field widget.
  • SpanningRole A widget that spans label and field columns.
See also
itemAt(), getItemPosition()
Enumerator
LabelRole 
FieldRole 
SpanningRole 

Definition at line 80 of file qformlayout.h.

◆ RowWrapPolicy

This enum specifies the different policies that can be used to control the way in which the form's rows wrap.

  • DontWrapRows Fields are always laid out next to their label. This is the default policy for all styles except Qt Extended styles and QS60Style.
  • WrapLongRows Labels are given enough horizontal space to fit the widest label, and the rest of the space is given to the fields. If the minimum size of a field pair is wider than the available space, the field is wrapped to the next line. This is the default policy for Qt Extended styles and and QS60Style.
  • WrapAllRows Fields are always laid out below their label.
See also
rowWrapPolicy
Enumerator
DontWrapRows 
WrapLongRows 
WrapAllRows 

Definition at line 74 of file qformlayout.h.

Constructors and Destructors

◆ QFormLayout()

QFormLayout::QFormLayout ( QWidget parent = 0)
explicit

Constructs a new form layout with the given parent widget.

See also
QWidget::setLayout()

Definition at line 1173 of file qformlayout.cpp.

1174  : QLayout(*new QFormLayoutPrivate, 0, parent)
1175 {
1176 }
QLayout()
Constructs a new child QLayout.
Definition: qlayout.cpp:127

◆ ~QFormLayout()

QFormLayout::~QFormLayout ( )

Destroys the form layout.

Definition at line 1181 of file qformlayout.cpp.

1182 {
1183  Q_D(QFormLayout);
1184 
1185  /*
1186  The clearing and destruction order here is important. We start by clearing
1187  m_things so that QLayout and the rest of the world know that we don't babysit
1188  the layout items anymore and don't care if they are destroyed.
1189  */
1190  d->m_things.clear();
1191  qDeleteAll(d->m_matrix.storage());
1192  d->m_matrix.clear();
1193 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ addItem()

void QFormLayout::addItem ( QLayoutItem item)
virtual

Reimplemented Function

Implements QLayout.

Definition at line 1392 of file qformlayout.cpp.

1393 {
1394  Q_D(QFormLayout);
1395 
1396  int row = d->insertRow(d->m_matrix.rowCount());
1397  d->setItem(row, FieldRole, item);
1398  invalidate();
1399 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ addRow() [1/6]

void QFormLayout::addRow ( QWidget label,
QWidget field 
)

Adds a new row to the bottom of this form layout, with the given label and field.

See also
insertRow()

Definition at line 1201 of file qformlayout.cpp.

1202 {
1203  insertRow(-1, label, field);
1204 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.

◆ addRow() [2/6]

void QFormLayout::addRow ( QWidget label,
QLayout field 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1209 of file qformlayout.cpp.

1210 {
1211  insertRow(-1, label, field);
1212 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.

◆ addRow() [3/6]

void QFormLayout::addRow ( const QString labelText,
QWidget field 
)

This overload automatically creates a QLabel behind the scenes with labelText as its text.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The field is set as the new QLabel's buddy.

Definition at line 1224 of file qformlayout.cpp.

1225 {
1226  insertRow(-1, labelText, field);
1227 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.

◆ addRow() [4/6]

void QFormLayout::addRow ( const QString labelText,
QLayout field 
)

This overload automatically creates a QLabel behind the scenes with labelText as its text.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1238 of file qformlayout.cpp.

1239 {
1240  insertRow(-1, labelText, field);
1241 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.

◆ addRow() [5/6]

void QFormLayout::addRow ( QWidget widget)

Adds the specified widget at the end of this form layout.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The widget spans both columns.

Definition at line 1252 of file qformlayout.cpp.

1253 {
1254  insertRow(-1, widget);
1255 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.

◆ addRow() [6/6]

void QFormLayout::addRow ( QLayout layout)

Adds the specified layout at the end of this form layout.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The layout spans both columns.

Definition at line 1266 of file qformlayout.cpp.

1267 {
1268  insertRow(-1, layout);
1269 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.

◆ count()

int QFormLayout::count ( ) const
virtual

Reimplemented Function

Implements QLayout.

Definition at line 1404 of file qformlayout.cpp.

Referenced by getLayoutPosition().

1405 {
1406  Q_D(const QFormLayout);
1407  return d->m_things.count();
1408 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ expandingDirections()

Qt::Orientations QFormLayout::expandingDirections ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 1462 of file qformlayout.cpp.

1463 {
1464  Q_D(const QFormLayout);
1465  QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d);
1466  e->updateSizes();
1467 
1468  Qt::Orientations o = 0;
1469  if (e->expandHorizontal)
1470  o = Qt::Horizontal;
1471  if (e->expandVertical)
1472  o |= Qt::Vertical;
1473  return o;
1474 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ fieldGrowthPolicy()

FieldGrowthPolicy QFormLayout::fieldGrowthPolicy ( ) const

Referenced by setFieldGrowthPolicy().

◆ formAlignment()

Qt::Alignment QFormLayout::formAlignment ( ) const

◆ getItemPosition()

void QFormLayout::getItemPosition ( int  index,
int *  rowPtr,
ItemRole rolePtr 
) const

Retrieves the row and role (column) of the item at the specified index.

If index is out of bounds, *rowPtr is set to -1; otherwise the row is stored in *rowPtr and the role is stored in *rolePtr.

See also
itemAt(), count(), getLayoutPosition(), getWidgetPosition()

Definition at line 1631 of file qformlayout.cpp.

Referenced by getLayoutPosition(), and getWidgetPosition().

1632 {
1633  Q_D(const QFormLayout);
1634  int col = -1;
1635  int row = -1;
1636 
1637  const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index));
1638  if (storageIndex != -1)
1639  QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col);
1640 
1641  if (rowPtr)
1642  *rowPtr = row;
1643  if (rolePtr && col != -1) {
1644  const bool spanning = col == 1 && d->m_matrix(row, col)->fullRow;
1645  if (spanning) {
1646  *rolePtr = SpanningRole;
1647  } else {
1648  *rolePtr = ItemRole(col);
1649  }
1650  }
1651 }
double d
Definition: qnumeric_p.h:62
ItemRole
This enum specifies the types of widgets (or other layout items) that may appear in a row...
Definition: qformlayout.h:80
#define Q_D(Class)
Definition: qglobal.h:2482
static int storageIndexFromLayoutItem(const QFormLayoutPrivate::ItemMatrix &m, QFormLayoutItem *item)
quint16 index
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ getLayoutPosition()

void QFormLayout::getLayoutPosition ( QLayout layout,
int *  rowPtr,
ItemRole rolePtr 
) const

Retrieves the row and role (column) of the specified child layout.

If layout is not in the form layout, *rowPtr is set to -1; otherwise the row is stored in *rowPtr and the role is stored in *rolePtr.

Definition at line 1659 of file qformlayout.cpp.

Referenced by labelForField().

1660 {
1661  int n = count();
1662  int index = 0;
1663  while (index < n) {
1664  if (itemAt(index) == layout)
1665  break;
1666  ++index;
1667  }
1668  getItemPosition(index, rowPtr, rolePtr);
1669 }
QLayoutItem * itemAt(int row, ItemRole role) const
Returns the layout item in the given row with the specified role (column).
int count() const
Reimplemented Function
quint16 index
void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const
Retrieves the row and role (column) of the item at the specified index.

◆ getWidgetPosition()

void QFormLayout::getWidgetPosition ( QWidget widget,
int *  rowPtr,
ItemRole rolePtr 
) const

Retrieves the row and role (column) of the specified widget in the layout.

If widget is not in the layout, *rowPtr is set to -1; otherwise the row is stored in *rowPtr and the role is stored in *rolePtr.

See also
getItemPosition(), itemAt()

Definition at line 1679 of file qformlayout.cpp.

Referenced by labelForField().

1680 {
1681  getItemPosition(indexOf(widget), rowPtr, rolePtr);
1682 }
virtual int indexOf(QWidget *) const
Searches for widget widget in this layout (not including child layouts).
Definition: qlayout.cpp:1378
void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const
Retrieves the row and role (column) of the item at the specified index.

◆ hasHeightForWidth()

bool QFormLayout::hasHeightForWidth ( ) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1479 of file qformlayout.cpp.

Referenced by heightForWidth(), and setGeometry().

1480 {
1481  Q_D(const QFormLayout);
1482  QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d);
1483  e->updateSizes();
1484  return (d->has_hfw || rowWrapPolicy() == WrapLongRows);
1485 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
RowWrapPolicy rowWrapPolicy() const
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ heightForWidth()

int QFormLayout::heightForWidth ( int  width) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1490 of file qformlayout.cpp.

1491 {
1492  Q_D(const QFormLayout);
1493  if (!hasHeightForWidth())
1494  return -1;
1495 
1496  int leftMargin, topMargin, rightMargin, bottomMargin;
1497  getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
1498 
1499  int targetWidth = width - leftMargin - rightMargin;
1500 
1501  if (!d->haveHfwCached(targetWidth)) {
1502  QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d);
1503  dat->setupVerticalLayoutData(targetWidth);
1504  dat->setupHorizontalLayoutData(targetWidth);
1505  dat->recalcHFW(targetWidth);
1506  }
1507  if (targetWidth == d->sh_width)
1508  return d->hfw_sh_height + topMargin + bottomMargin;
1509  else
1510  return d->hfw_height + topMargin + bottomMargin;
1511 }
bool hasHeightForWidth() const
Reimplemented Function
double d
Definition: qnumeric_p.h:62
void setupVerticalLayoutData(int width)
#define Q_D(Class)
Definition: qglobal.h:2482
void setupHorizontalLayoutData(int width)
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
Definition: qlayout.cpp:551
void recalcHFW(int w)
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ horizontalSpacing()

int QFormLayout::horizontalSpacing ( ) const

Referenced by setHorizontalSpacing(), and spacing().

◆ insertRow() [1/6]

void QFormLayout::insertRow ( int  row,
QWidget label,
QWidget field 
)

Inserts a new row at position row in this form layout, with the given label and field.

If row is out of bounds, the new row is added at the end.

See also
addRow()

Definition at line 1278 of file qformlayout.cpp.

Referenced by addRow(), and insertRow().

1279 {
1280  Q_D(QFormLayout);
1281 
1282  row = d->insertRow(row);
1283  if (label)
1284  d->setWidget(row, LabelRole, label);
1285  if (field)
1286  d->setWidget(row, FieldRole, field);
1287  invalidate();
1288 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ insertRow() [2/6]

void QFormLayout::insertRow ( int  row,
QWidget label,
QLayout field 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1293 of file qformlayout.cpp.

1294 {
1295  Q_D(QFormLayout);
1296 
1297  row = d->insertRow(row);
1298  if (label)
1299  d->setWidget(row, LabelRole, label);
1300  if (field)
1301  d->setLayout(row, FieldRole, field);
1302  invalidate();
1303 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ insertRow() [3/6]

void QFormLayout::insertRow ( int  row,
const QString labelText,
QWidget field 
)

This overload automatically creates a QLabel behind the scenes with labelText as its text.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The field is set as the new QLabel's buddy.

Definition at line 1315 of file qformlayout.cpp.

1316 {
1317  QLabel *label = 0;
1318  if (!labelText.isEmpty()) {
1319  label = new QLabel(labelText);
1320 #ifndef QT_NO_SHORTCUT
1321  label->setBuddy(field);
1322 #endif
1323  }
1324  insertRow(row, label, field);
1325 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setBuddy(QWidget *)
Sets this label&#39;s buddy to buddy.
Definition: qlabel.cpp:1297
The QLabel widget provides a text or image display.
Definition: qlabel.h:55

◆ insertRow() [4/6]

void QFormLayout::insertRow ( int  row,
const QString labelText,
QLayout field 
)

This overload automatically creates a QLabel behind the scenes with labelText as its text.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1336 of file qformlayout.cpp.

1337 {
1338  insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field);
1339 }
void insertRow(int row, QWidget *label, QWidget *field)
Inserts a new row at position row in this form layout, with the given label and field.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QLabel widget provides a text or image display.
Definition: qlabel.h:55

◆ insertRow() [5/6]

void QFormLayout::insertRow ( int  row,
QWidget widget 
)

Inserts the specified widget at position row in this form layout.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The widget spans both columns. If row is out of bounds, the widget is added at the end.

Definition at line 1351 of file qformlayout.cpp.

1352 {
1353  Q_D(QFormLayout);
1354 
1355  if (!widget) {
1356  qWarning("QFormLayout: Cannot add null field to %s", qPrintable(objectName()));
1357  return;
1358  }
1359 
1360  row = d->insertRow(row);
1361  d->setWidget(row, SpanningRole, widget);
1362  invalidate();
1363 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
QString objectName() const
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
#define qPrintable(string)
Definition: qglobal.h:1750

◆ insertRow() [6/6]

void QFormLayout::insertRow ( int  row,
QLayout layout 
)

Inserts the specified layout at position row in this form layout.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The layout spans both columns. If row is out of bounds, the widget is added at the end.

Definition at line 1375 of file qformlayout.cpp.

1376 {
1377  Q_D(QFormLayout);
1378 
1379  if (!layout) {
1380  qWarning("QFormLayout: Cannot add null field to %s", qPrintable(objectName()));
1381  return;
1382  }
1383 
1384  row = d->insertRow(row);
1385  d->setLayout(row, SpanningRole, layout);
1386  invalidate();
1387 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
QString objectName() const
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
#define qPrintable(string)
Definition: qglobal.h:1750

◆ invalidate()

void QFormLayout::invalidate ( )
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1571 of file qformlayout.cpp.

Referenced by addItem(), insertRow(), setFieldGrowthPolicy(), setFormAlignment(), setHorizontalSpacing(), setLabelAlignment(), setRowWrapPolicy(), setSpacing(), setVerticalSpacing(), and takeAt().

1572 {
1573  Q_D(QFormLayout);
1574  d->dirty = true;
1575  d->sizesDirty = true;
1576  d->minSize = QSize();
1577  d->prefSize = QSize();
1578  d->formMaxWidth = -1;
1579  d->hfw_width = -1;
1580  d->sh_width = -1;
1581  d->layoutWidth = -1;
1582  d->hfw_sh_height = -1;
1584 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ itemAt() [1/2]

QLayoutItem * QFormLayout::itemAt ( int  row,
ItemRole  role 
) const

Returns the layout item in the given row with the specified role (column).

Returns 0 if there is no such item.

See also
QLayout::itemAt(), setItem()

Definition at line 1603 of file qformlayout.cpp.

Referenced by getLayoutPosition().

1604 {
1605  Q_D(const QFormLayout);
1606  if (uint(row) >= uint(d->m_matrix.rowCount()))
1607  return 0;
1608  switch (role) {
1609  case SpanningRole:
1610  if (QFormLayoutItem *item = d->m_matrix(row, 1))
1611  if (item->fullRow)
1612  return item->item;
1613  break;
1614  case LabelRole:
1615  case FieldRole:
1616  if (QFormLayoutItem *item = d->m_matrix(row, (role == LabelRole) ? 0 : 1))
1617  return item->item;
1618  break;
1619  }
1620  return 0;
1621 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
unsigned int uint
Definition: qglobal.h:996
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ itemAt() [2/2]

QLayoutItem * QFormLayout::itemAt ( int  index) const
virtual

Reimplemented Function

Implements QLayout.

Definition at line 1413 of file qformlayout.cpp.

1414 {
1415  Q_D(const QFormLayout);
1416  if (QFormLayoutItem *formItem = d->m_things.value(index))
1417  return formItem->item;
1418  return 0;
1419 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ labelAlignment()

Qt::Alignment QFormLayout::labelAlignment ( ) const

Referenced by setLabelAlignment().

◆ labelForField() [1/2]

QWidget * QFormLayout::labelForField ( QWidget field) const

Returns the label associated with the given field.

See also
itemAt()

Definition at line 1691 of file qformlayout.cpp.

1692 {
1693  Q_D(const QFormLayout);
1694 
1695  int row;
1696  ItemRole role;
1697 
1698  getWidgetPosition(field, &row, &role);
1699 
1700  if (row != -1 && role == FieldRole) {
1701  if (QFormLayoutItem *label = d->m_matrix(row, LabelRole))
1702  return label->widget();
1703  }
1704  return 0;
1705 }
double d
Definition: qnumeric_p.h:62
ItemRole
This enum specifies the types of widgets (or other layout items) that may appear in a row...
Definition: qformlayout.h:80
#define Q_D(Class)
Definition: qglobal.h:2482
void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const
Retrieves the row and role (column) of the specified widget in the layout.
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ labelForField() [2/2]

QWidget * QFormLayout::labelForField ( QLayout field) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1710 of file qformlayout.cpp.

1711 {
1712  Q_D(const QFormLayout);
1713 
1714  int row;
1715  ItemRole role;
1716 
1717  getLayoutPosition(field, &row, &role);
1718 
1719  if (row != -1 && role == FieldRole) {
1720  if (QFormLayoutItem *label = d->m_matrix(row, LabelRole))
1721  return label->widget();
1722  }
1723  return 0;
1724 }
double d
Definition: qnumeric_p.h:62
ItemRole
This enum specifies the types of widgets (or other layout items) that may appear in a row...
Definition: qformlayout.h:80
#define Q_D(Class)
Definition: qglobal.h:2482
void getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const
Retrieves the row and role (column) of the specified child layout.
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ minimumSize()

QSize QFormLayout::minimumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 1557 of file qformlayout.cpp.

1558 {
1559  // ### fix minimumSize if hfw
1560  Q_D(const QFormLayout);
1561  if (!d->minSize.isValid()) {
1562  QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d);
1563  dat->calcSizeHints();
1564  }
1565  return d->minSize;
1566 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ resetFieldGrowthPolicy()

void QFormLayout::resetFieldGrowthPolicy ( )
private
Warning
This function is not part of the public interface.

Definition at line 2090 of file qformlayout.cpp.

2091 {
2092  Q_D(QFormLayout);
2093  d->fieldGrowthPolicy = DefaultFieldGrowthPolicy;
2094 }
const uint DefaultFieldGrowthPolicy
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ resetFormAlignment()

void QFormLayout::resetFormAlignment ( )
private
Warning
This function is not part of the public interface.

Definition at line 2110 of file qformlayout.cpp.

2111 {
2112  Q_D(QFormLayout);
2113  d->formAlignment = 0;
2114 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ resetLabelAlignment()

void QFormLayout::resetLabelAlignment ( )
private
Warning
This function is not part of the public interface.

Definition at line 2120 of file qformlayout.cpp.

2121 {
2122  Q_D(QFormLayout);
2123  d->labelAlignment = 0;
2124 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ resetRowWrapPolicy()

void QFormLayout::resetRowWrapPolicy ( )
private
Warning
This function is not part of the public interface.

Definition at line 2100 of file qformlayout.cpp.

2101 {
2102  Q_D(QFormLayout);
2103  d->rowWrapPolicy = DefaultRowWrapPolicy;
2104 }
double d
Definition: qnumeric_p.h:62
const uint DefaultRowWrapPolicy
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ rowCount()

int QFormLayout::rowCount ( ) const

Returns the number of rows in the form.

See also
QLayout::count()

Definition at line 1591 of file qformlayout.cpp.

Referenced by resetLabelAlignment(), setItem(), setLayout(), and setWidget().

1592 {
1593  Q_D(const QFormLayout);
1594  return d->m_matrix.rowCount();
1595 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ rowWrapPolicy()

RowWrapPolicy QFormLayout::rowWrapPolicy ( ) const

◆ setFieldGrowthPolicy()

void QFormLayout::setFieldGrowthPolicy ( FieldGrowthPolicy  policy)

Definition at line 1746 of file qformlayout.cpp.

Referenced by QPrintPreviewDialogPrivate::init().

1747 {
1748  Q_D(QFormLayout);
1749  if (FieldGrowthPolicy(d->fieldGrowthPolicy) != policy) {
1750  d->fieldGrowthPolicy = policy;
1751  invalidate();
1752  }
1753 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
FieldGrowthPolicy
This enum specifies the different policies that can be used to control the way in which the form&#39;s fi...
Definition: qformlayout.h:68
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setFormAlignment()

void QFormLayout::setFormAlignment ( Qt::Alignment  alignment)

Definition at line 1849 of file qformlayout.cpp.

1850 {
1851  Q_D(QFormLayout);
1852  if (d->formAlignment != alignment) {
1853  d->formAlignment = alignment;
1854  invalidate();
1855  }
1856 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setGeometry()

void QFormLayout::setGeometry ( const QRect rect)
virtual

Reimplemented Function

Reimplemented from QLayout.

Definition at line 1516 of file qformlayout.cpp.

1517 {
1518  Q_D(QFormLayout);
1519  if (d->dirty || rect != geometry()) {
1520  QRect cr = rect;
1521  int leftMargin, topMargin, rightMargin, bottomMargin;
1522  getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
1523  cr.adjust(+leftMargin, +topMargin, -rightMargin, -bottomMargin);
1524 
1525  bool hfw = hasHeightForWidth();
1526  d->setupVerticalLayoutData(cr.width());
1527  d->setupHorizontalLayoutData(cr.width());
1528  if (hfw && (!d->haveHfwCached(cr.width()) || d->hfwLayouts.size() != d->vLayoutCount))
1529  d->recalcHFW(cr.width());
1530  if (hfw) {
1531  qGeomCalc(d->hfwLayouts, 0, d->vLayoutCount, cr.y(), cr.height());
1532  d->arrangeWidgets(d->hfwLayouts, cr);
1533  } else {
1534  qGeomCalc(d->vLayouts, 0, d->vLayoutCount, cr.y(), cr.height());
1535  d->arrangeWidgets(d->vLayouts, cr);
1536  }
1537  QLayout::setGeometry(rect);
1538  }
1539 }
bool hasHeightForWidth() const
Reimplemented Function
double d
Definition: qnumeric_p.h:62
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
virtual void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
Definition: qlayout.cpp:551
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
QRect geometry() const
Reimplemented Function
Definition: qlayout.cpp:664

◆ setHorizontalSpacing()

void QFormLayout::setHorizontalSpacing ( int  spacing)

Definition at line 1881 of file qformlayout.cpp.

1882 {
1883  Q_D(QFormLayout);
1884  if (spacing != d->hSpacing) {
1885  d->hSpacing = spacing;
1886  invalidate();
1887  }
1888 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setItem()

void QFormLayout::setItem ( int  row,
ItemRole  role,
QLayoutItem item 
)

Sets the item in the given row for the given role to item, extending the layout with empty rows if necessary.

If the cell is already occupied, the item is not inserted and an error message is sent to the console. The item spans both columns.

Warning
Do not use this function to add child layouts or child widget items. Use setLayout() or setWidget() instead.
See also
setLayout()

Definition at line 2077 of file qformlayout.cpp.

2078 {
2079  Q_D(QFormLayout);
2080  int rowCnt = rowCount();
2081  if (row >= rowCnt)
2082  d->insertRows(rowCnt, row - rowCnt + 1);
2083  d->setItem(row, role, item);
2084 }
double d
Definition: qnumeric_p.h:62
int rowCount() const
Returns the number of rows in the form.
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setLabelAlignment()

void QFormLayout::setLabelAlignment ( Qt::Alignment  alignment)

Definition at line 1816 of file qformlayout.cpp.

1817 {
1818  Q_D(QFormLayout);
1819  if (d->labelAlignment != alignment) {
1820  d->labelAlignment = alignment;
1821  invalidate();
1822  }
1823 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setLayout()

void QFormLayout::setLayout ( int  row,
ItemRole  role,
QLayout layout 
)

Sets the sub-layout in the given row for the given role to layout, extending the form layout with empty rows if necessary.

If the cell is already occupied, the layout is not inserted and an error message is sent to the console.

Note: For most applications, addRow() or insertRow() should be used instead of setLayout().

See also
setWidget()

Definition at line 2055 of file qformlayout.cpp.

2056 {
2057  Q_D(QFormLayout);
2058  int rowCnt = rowCount();
2059  if (row >= rowCnt)
2060  d->insertRows(rowCnt, row - rowCnt + 1);
2061  d->setLayout(row, role, layout);
2062 }
double d
Definition: qnumeric_p.h:62
int rowCount() const
Returns the number of rows in the form.
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setRowWrapPolicy()

void QFormLayout::setRowWrapPolicy ( RowWrapPolicy  policy)

Definition at line 1782 of file qformlayout.cpp.

1783 {
1784  Q_D(QFormLayout);
1785  if (RowWrapPolicy(d->rowWrapPolicy) != policy) {
1786  d->rowWrapPolicy = policy;
1787  invalidate();
1788  }
1789 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
RowWrapPolicy
This enum specifies the different policies that can be used to control the way in which the form&#39;s ro...
Definition: qformlayout.h:74

◆ setSpacing()

void QFormLayout::setSpacing ( int  spacing)

This function sets both the vertical and horizontal spacing to spacing.

See also
setVerticalSpacing(), setHorizontalSpacing()

Definition at line 1938 of file qformlayout.cpp.

1939 {
1940  Q_D(QFormLayout);
1941  d->vSpacing = d->hSpacing = spacing;
1942  invalidate();
1943 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setVerticalSpacing()

void QFormLayout::setVerticalSpacing ( int  spacing)

Definition at line 1913 of file qformlayout.cpp.

1914 {
1915  Q_D(QFormLayout);
1916  if (spacing != d->vSpacing) {
1917  d->vSpacing = spacing;
1918  invalidate();
1919  }
1920 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ setWidget()

void QFormLayout::setWidget ( int  row,
ItemRole  role,
QWidget widget 
)

Sets the widget in the given row for the given role to widget, extending the layout with empty rows if necessary.

If the cell is already occupied, the widget is not inserted and an error message is sent to the console.

Note: For most applications, addRow() or insertRow() should be used instead of setWidget().

See also
setLayout()

Definition at line 2035 of file qformlayout.cpp.

Referenced by QPrintPreviewDialogPrivate::init().

2036 {
2037  Q_D(QFormLayout);
2038  int rowCnt = rowCount();
2039  if (row >= rowCnt)
2040  d->insertRows(rowCnt, row - rowCnt + 1);
2041  d->setWidget(row, role, widget);
2042 }
double d
Definition: qnumeric_p.h:62
int rowCount() const
Returns the number of rows in the form.
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ sizeHint()

QSize QFormLayout::sizeHint ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 1544 of file qformlayout.cpp.

1545 {
1546  Q_D(const QFormLayout);
1547  if (!d->prefSize.isValid()) {
1548  QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d);
1549  dat->calcSizeHints();
1550  }
1551  return d->prefSize;
1552 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ spacing()

int QFormLayout::spacing ( ) const

If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it returns -1.

See also
setSpacing(), verticalSpacing(), horizontalSpacing()

Definition at line 1951 of file qformlayout.cpp.

Referenced by setHorizontalSpacing(), setSpacing(), and setVerticalSpacing().

1952 {
1953  int hSpacing = horizontalSpacing();
1954  if (hSpacing == verticalSpacing()) {
1955  return hSpacing;
1956  } else {
1957  return -1;
1958  }
1959 }
int verticalSpacing() const
int horizontalSpacing() const

◆ takeAt()

QLayoutItem * QFormLayout::takeAt ( int  index)
virtual

Reimplemented Function

Implements QLayout.

Definition at line 1424 of file qformlayout.cpp.

1425 {
1426  Q_D(QFormLayout);
1427 
1428  const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index));
1429  if (storageIndex == -1) {
1430  qWarning("QFormLayout::takeAt: Invalid index %d", index);
1431  return 0;
1432  }
1433 
1434  int row, col;
1435  QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col);
1436  Q_ASSERT(d->m_matrix(row, col));
1437 
1438  QFormLayoutItem *item = d->m_matrix(row, col);
1439  Q_ASSERT(item);
1440  d->m_things.removeAt(index);
1441  d->m_matrix(row, col) = 0;
1442 
1443  invalidate();
1444 
1445  // grab ownership back from the QFormLayoutItem
1446  QLayoutItem *i = item->item;
1447  item->item = 0;
1448  delete item;
1449 
1450  if (QLayout *l = i->layout()) {
1451  // sanity check in case the user passed something weird to QObject::setParent()
1452  if (l->parent() == this)
1453  l->setParent(0);
1454  }
1455 
1456  return i;
1457 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
Q_CORE_EXPORT void qWarning(const char *,...)
static int storageIndexFromLayoutItem(const QFormLayoutPrivate::ItemMatrix &m, QFormLayoutItem *item)
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QFactoryLoader * l
quint16 index
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55

◆ verticalSpacing()

int QFormLayout::verticalSpacing ( ) const

Referenced by setVerticalSpacing(), and spacing().

Properties

◆ fieldGrowthPolicy

QFormLayout::FieldGrowthPolicy QFormLayout::fieldGrowthPolicy
private

the way in which the form's fields grow

The default value depends on the widget or application style. For QMacStyle, the default is FieldsStayAtSizeHint; for QCommonStyle derived styles (like Plastique and Windows), the default is ExpandingFieldsGrow; for Qt Extended styles, the default is AllNonFixedFieldsGrow.

If none of the fields can grow and the form is resized, extra space is distributed according to the current form alignment.

See also
formAlignment, rowWrapPolicy

Definition at line 60 of file qformlayout.h.

◆ formAlignment

Qt::Alignment QFormLayout::formAlignment
private

the alignment of the form layout's contents within the layout's geometry

The default value depends on the widget or application style. For QMacStyle, the default is Qt::AlignHCenter | Qt::AlignTop; for the other styles, the default is Qt::AlignLeft | Qt::AlignTop.

See also
labelAlignment, rowWrapPolicy

Definition at line 63 of file qformlayout.h.

◆ horizontalSpacing

int QFormLayout::horizontalSpacing
private

the spacing between widgets that are laid out side by side

By default, if no value is explicitly set, the layout's horizontal spacing is inherited from the parent layout, or from the style settings for the parent widget.

See also
verticalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing}

Definition at line 64 of file qformlayout.h.

◆ labelAlignment

Qt::Alignment QFormLayout::labelAlignment
private

the horizontal alignment of the labels

The default value depends on the widget or application style. For QCommonStyle derived styles, except for QPlastiqueStyle, the default is Qt::AlignLeft; for the other styles, the default is Qt::AlignRight.

See also
formAlignment

Definition at line 62 of file qformlayout.h.

◆ rowWrapPolicy

QFormLayout::RowWrapPolicy QFormLayout::rowWrapPolicy
private

the way in which the form's rows wrap

The default value depends on the widget or application style. For Qt Extended styles and QS60Style, the default is WrapLongRows; for the other styles, the default is DontWrapRows.

If you want to display each label above its associated field (instead of next to it), set this property to WrapAllRows.

See also
fieldGrowthPolicy

Definition at line 61 of file qformlayout.h.

◆ verticalSpacing

int QFormLayout::verticalSpacing
private

the spacing between widgets that are laid out vertically

By default, if no value is explicitly set, the layout's vertical spacing is inherited from the parent layout, or from the style settings for the parent widget.

See also
horizontalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing}

Definition at line 65 of file qformlayout.h.


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