QtBase  v6.3.1
Classes | Public Types | Public Member 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:
Inheritance graph
[legend]
Collaboration diagram for QFormLayout:
Collaboration graph
[legend]

Classes

class  TakeRowResult
 Contains the result of a QFormLayout::takeRow() call. \inmodule QtWidgets. More...
 

Public Types

enum  FieldGrowthPolicy { FieldsStayAtSizeHint , ExpandingFieldsGrow , AllNonFixedFieldsGrow }
 
enum  RowWrapPolicy { DontWrapRows , WrapLongRows , WrapAllRows }
 
enum  ItemRole { LabelRole = 0 , FieldRole = 1 , SpanningRole = 2 }
 
- Public Types inherited from QLayout
enum  SizeConstraint {
  SetDefaultConstraint , SetNoConstraint , SetMinimumSize , SetFixedSize ,
  SetMaximumSize , SetMinAndMaxSize
}
 

Public Member Functions

 QFormLayout (QWidget *parent=nullptr)
 
 ~QFormLayout ()
 
void setFieldGrowthPolicy (FieldGrowthPolicy policy)
 
FieldGrowthPolicy fieldGrowthPolicy () const
 
void setRowWrapPolicy (RowWrapPolicy policy)
 
RowWrapPolicy rowWrapPolicy () const
 
void setLabelAlignment (Qt::Alignment alignment)
 
Qt::Alignment labelAlignment () const
 
void setFormAlignment (Qt::Alignment alignment)
 
Qt::Alignment formAlignment () const
 
void setHorizontalSpacing (int spacing)
 
int horizontalSpacing () const
 
void setVerticalSpacing (int spacing)
 
int verticalSpacing () const
 
int spacing () const override
 
void setSpacing (int) override
 
void addRow (QWidget *label, QWidget *field)
 
void addRow (QWidget *label, QLayout *field)
 
void addRow (const QString &labelText, QWidget *field)
 
void addRow (const QString &labelText, QLayout *field)
 
void addRow (QWidget *widget)
 
void addRow (QLayout *layout)
 
void insertRow (int row, QWidget *label, QWidget *field)
 
void insertRow (int row, QWidget *label, QLayout *field)
 
void insertRow (int row, const QString &labelText, QWidget *field)
 
void insertRow (int row, const QString &labelText, QLayout *field)
 
void insertRow (int row, QWidget *widget)
 
void insertRow (int row, QLayout *layout)
 
void removeRow (int row)
 
void removeRow (QWidget *widget)
 
void removeRow (QLayout *layout)
 
TakeRowResult takeRow (int row)
 
TakeRowResult takeRow (QWidget *widget)
 
TakeRowResult takeRow (QLayout *layout)
 
void setItem (int row, ItemRole role, QLayoutItem *item)
 
void setWidget (int row, ItemRole role, QWidget *widget)
 
void setLayout (int row, ItemRole role, QLayout *layout)
 
QLayoutItemitemAt (int row, ItemRole role) const
 
void getItemPosition (int index, int *rowPtr, ItemRole *rolePtr) const
 
void getWidgetPosition (QWidget *widget, int *rowPtr, ItemRole *rolePtr) const
 
void getLayoutPosition (QLayout *layout, int *rowPtr, ItemRole *rolePtr) const
 
QWidgetlabelForField (QWidget *field) const
 
QWidgetlabelForField (QLayout *field) const
 
void addItem (QLayoutItem *item) override
 
QLayoutItemitemAt (int index) const override
 
QLayoutItemtakeAt (int index) override
 
void setGeometry (const QRect &rect) override
 
QSize minimumSize () const override
 
QSize sizeHint () const override
 
void invalidate () override
 
bool hasHeightForWidth () const override
 
int heightForWidth (int width) const override
 
Qt::Orientations expandingDirections () const override
 
int count () const override
 
int rowCount () const
 
- Public Member Functions inherited from QLayout
 QLayout (QWidget *parent=nullptr)
 
 ~QLayout ()
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContentsMargins (const QMargins &margins)
 
void unsetContentsMargins ()
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
bool setAlignment (QWidget *w, Qt::Alignment alignment)
 
bool setAlignment (QLayout *l, Qt::Alignment alignment)
 
void setSizeConstraint (SizeConstraint)
 
SizeConstraint sizeConstraint () const
 
void setMenuBar (QWidget *w)
 
QWidgetmenuBar () const
 
QWidgetparentWidget () const
 
void invalidate () override
 
QRect geometry () const override
 
bool activate ()
 
void update ()
 
void addWidget (QWidget *w)
 
void removeWidget (QWidget *w)
 
void removeItem (QLayoutItem *)
 
Qt::Orientations expandingDirections () const override
 
QSize minimumSize () const override
 
QSize maximumSize () const override
 
virtual int indexOf (const QWidget *) const
 
virtual int indexOf (const QLayoutItem *) const
 
bool isEmpty () const override
 
QSizePolicy::ControlTypes controlTypes () const override
 
virtual QLayoutItemreplaceWidget (QWidget *from, QWidget *to, Qt::FindChildOptions options=Qt::FindChildrenRecursively)
 
int totalMinimumHeightForWidth (int w) const
 
int totalHeightForWidth (int w) const
 
QSize totalMinimumSize () const
 
QSize totalMaximumSize () const
 
QSize totalSizeHint () const
 
QLayoutlayout () override
 
void setEnabled (bool)
 
bool isEnabled () const
 
void setAlignment (Qt::Alignment a)
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 
- Public Member Functions inherited from QLayoutItem
 QLayoutItem (Qt::Alignment alignment=Qt::Alignment())
 
virtual ~QLayoutItem ()
 
virtual int minimumHeightForWidth (int) const
 
virtual QWidgetwidget () const
 
virtual QSpacerItemspacerItem ()
 
Qt::Alignment alignment () const
 
void setAlignment (Qt::Alignment a)
 

Properties

FieldGrowthPolicy fieldGrowthPolicy
 the way in which the form's fields grow More...
 
RowWrapPolicy rowWrapPolicy
 the way in which the form's rows wrap More...
 
Qt::Alignment labelAlignment
 the horizontal alignment of the labels 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...
 
int verticalSpacing
 the spacing between widgets that are laid out vertically More...
 
- Properties inherited from QLayout
int spacing
 the spacing between widgets inside the layout More...
 
QMargins contentsMargins
 
SizeConstraint sizeConstraint
 the resize mode of the layout More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 
- Static Public Member Functions inherited from QLayout
static QSize closestAcceptableSize (const QWidget *w, const QSize &s)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Member Functions inherited from QLayout
void widgetEvent (QEvent *)
 
void childEvent (QChildEvent *e) override
 
void addChildLayout (QLayout *l)
 
void addChildWidget (QWidget *w)
 
bool adoptLayout (QLayout *layout)
 
QRect alignmentRect (const QRect &) const
 
 QLayout (QLayoutPrivate &d, QLayout *, QWidget *)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Attributes inherited from QLayoutItem
Qt::Alignment align
 

Detailed Description

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

Since
4.4

\inmodule QtWidgets

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:

\list

For devices with small displays, QFormLayout can be set to \l{WrapLongRows}{wrap long rows}, or even to \l{WrapAllRows}{wrap all rows}.

The addRow() overload that takes a QString and a QWidget * creates a QLabel behind the scenes and automatically set up its buddy. We can then write code like this:

Compare this with the following code, written using QGridLayout:

\endlist

The table below shows the default appearance in different styles.

\table \header

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 53 of file qformlayout.h.

Member Enumeration Documentation

◆ FieldGrowthPolicy

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

\value FieldsStayAtSizeHint The fields never grow beyond their \l{QWidgetItem::sizeHint()}{effective size hint}. This is the default for QMacStyle.

\value ExpandingFieldsGrow Fields with an horizontal \l{QSizePolicy}{size policy} of \l{QSizePolicy::}{Expanding} or \l{QSizePolicy::}{MinimumExpanding} will grow to fill the available space. The other fields will not grow beyond their effective size hint. This is the default policy for Plastique.

\value 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 69 of file qformlayout.h.

◆ ItemRole

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

\value LabelRole A label widget. \value FieldRole A field widget. \value SpanningRole A widget that spans label and field columns.

See also
itemAt(), getItemPosition()
Enumerator
LabelRole 
FieldRole 
SpanningRole 

Definition at line 83 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.

\value DontWrapRows Fields are always laid out next to their label. This is the default policy for all styles except Qt Extended styles.

\value 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.

\value WrapAllRows Fields are always laid out below their label.

See also
rowWrapPolicy
Enumerator
DontWrapRows 
WrapLongRows 
WrapAllRows 

Definition at line 76 of file qformlayout.h.

Constructor & Destructor Documentation

◆ QFormLayout()

QFormLayout::QFormLayout ( QWidget parent = nullptr)
explicit

\variable QFormLayout::TakeRowResult::labelItem

Contains the layout item corresponding to the label of the row.

\variable QFormLayout::TakeRowResult::fieldItem

Contains the layout item corresponding to the field of the row.

Constructs a new form layout with the given parent widget.

The layout is set directly as the top-level layout for parent. There can be only one top-level layout for a widget. It is returned by QWidget::layout().

See also
QWidget::setLayout()

Definition at line 1198 of file qformlayout.cpp.

◆ ~QFormLayout()

QFormLayout::~QFormLayout ( )

Destroys the form layout.

Definition at line 1206 of file qformlayout.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addItem()

void QFormLayout::addItem ( QLayoutItem item)
overridevirtual

\reimp

Implements QLayout.

Definition at line 1634 of file qformlayout.cpp.

Here is the call graph for this function:

◆ addRow() [1/6]

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

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

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

Definition at line 1257 of file qformlayout.cpp.

Here is the call graph for this function:

◆ addRow() [2/6]

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

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

This overload automatically creates a QLabel behind the scenes with labelText as its text. The field is set as the new QLabel's \l{QLabel::setBuddy()}{buddy}.

Definition at line 1246 of file qformlayout.cpp.

Here is the call graph for this function:

◆ addRow() [3/6]

void QFormLayout::addRow ( QLayout layout)

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

Adds the specified layout at the end of this form layout. The layout spans both columns.

Definition at line 1279 of file qformlayout.cpp.

Here is the call graph for this function:

◆ addRow() [4/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 1234 of file qformlayout.cpp.

Here is the call graph for this function:

◆ addRow() [5/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 1226 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addRow() [6/6]

void QFormLayout::addRow ( QWidget widget)

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

Adds the specified widget at the end of this form layout. The widget spans both columns.

Definition at line 1268 of file qformlayout.cpp.

Here is the call graph for this function:

◆ count()

int QFormLayout::count ( ) const
overridevirtual

\reimp

Implements QLayout.

Definition at line 1646 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ expandingDirections()

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

\reimp

Implements QLayoutItem.

Definition at line 1693 of file qformlayout.cpp.

◆ fieldGrowthPolicy()

QFormLayout::FieldGrowthPolicy QFormLayout::fieldGrowthPolicy ( ) const

Definition at line 1983 of file qformlayout.cpp.

◆ formAlignment()

Qt::Alignment QFormLayout::formAlignment ( ) const

Definition at line 2077 of file qformlayout.cpp.

◆ 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 1862 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ 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 1890 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1910 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasHeightForWidth()

bool QFormLayout::hasHeightForWidth ( ) const
overridevirtual

\reimp

Reimplemented from QLayoutItem.

Definition at line 1710 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ heightForWidth()

int QFormLayout::heightForWidth ( int  width) const
overridevirtual

\reimp

Reimplemented from QLayoutItem.

Definition at line 1721 of file qformlayout.cpp.

Here is the call graph for this function:

◆ horizontalSpacing()

int QFormLayout::horizontalSpacing ( ) const

Definition at line 2106 of file qformlayout.cpp.

Here is the call graph for this function:

◆ insertRow() [1/6]

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

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

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

Definition at line 1351 of file qformlayout.cpp.

Here is the call graph for this function:

◆ insertRow() [2/6]

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

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

This overload automatically creates a QLabel behind the scenes with labelText as its text. The field is set as the new QLabel's \l{QLabel::setBuddy()}{buddy}.

Definition at line 1329 of file qformlayout.cpp.

Here is the call graph for this function:

◆ insertRow() [3/6]

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

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

Inserts the specified layout at position row in this form layout. The layout spans both columns. If row is out of bounds, the widget is added at the end.

Definition at line 1385 of file qformlayout.cpp.

Here is the call graph for this function:

◆ insertRow() [4/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 1308 of file qformlayout.cpp.

Here is the call graph for this function:

◆ insertRow() [5/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 1291 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertRow() [6/6]

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

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

Inserts the specified widget at position row in this form layout. The widget spans both columns. If row is out of bounds, the widget is added at the end.

Definition at line 1367 of file qformlayout.cpp.

Here is the call graph for this function:

◆ invalidate()

void QFormLayout::invalidate ( )
overridevirtual

\reimp

Reimplemented from QLayoutItem.

Definition at line 1802 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemAt() [1/2]

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

\reimp

Implements QLayout.

Definition at line 1655 of file qformlayout.cpp.

◆ itemAt() [2/2]

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

Returns the layout item in the given row with the specified role (column). Returns \nullptr if there is no such item.

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

Definition at line 1834 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ labelAlignment()

Qt::Alignment QFormLayout::labelAlignment ( ) const

Definition at line 2047 of file qformlayout.cpp.

◆ labelForField() [1/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 1941 of file qformlayout.cpp.

Here is the call graph for this function:

◆ labelForField() [2/2]

QWidget * QFormLayout::labelForField ( QWidget field) const

Returns the label associated with the given field.

See also
itemAt()

Definition at line 1922 of file qformlayout.cpp.

Here is the call graph for this function:

◆ minimumSize()

QSize QFormLayout::minimumSize ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 1788 of file qformlayout.cpp.

Here is the call graph for this function:

◆ removeRow() [1/3]

void QFormLayout::removeRow ( int  row)
Since
5.8

Deletes row row from this form layout.

row must be non-negative and less than rowCount().

After this call, rowCount() is decremented by one. All widgets and nested layouts that occupied this row are deleted. That includes both the field widget(s) and the label, if any. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows.

You can use this function to undo a previous addRow() or insertRow():

If you want to remove the row from the layout without deleting the widgets, use takeRow() instead.

See also
takeRow()

Definition at line 1446 of file qformlayout.cpp.

Here is the call graph for this function:

◆ removeRow() [2/3]

void QFormLayout::removeRow ( QLayout layout)
Since
5.8

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

Deletes the row corresponding to layout from this form layout.

After this call, rowCount() is decremented by one. All widgets and nested layouts that occupied this row are deleted. That includes both the field widget(s) and the label, if any. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows.

You can use this function to undo a previous addRow() or insertRow():

If you want to remove the row from the form layout without deleting the inserted layout, use takeRow() instead.

See also
takeRow()

Definition at line 1499 of file qformlayout.cpp.

Here is the call graph for this function:

◆ removeRow() [3/3]

void QFormLayout::removeRow ( QWidget widget)
Since
5.8

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

Deletes the row corresponding to widget from this form layout.

After this call, rowCount() is decremented by one. All widgets and nested layouts that occupied this row are deleted. That includes both the field widget(s) and the label, if any. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows.

You can use this function to undo a previous addRow() or insertRow():

If you want to remove the row from the layout without deleting the widgets, use takeRow() instead.

See also
takeRow()

Definition at line 1472 of file qformlayout.cpp.

Here is the call graph for this function:

◆ rowCount()

int QFormLayout::rowCount ( ) const

Returns the number of rows in the form.

See also
QLayout::count()

Definition at line 1822 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ rowWrapPolicy()

QFormLayout::RowWrapPolicy QFormLayout::rowWrapPolicy ( ) const

Definition at line 2016 of file qformlayout.cpp.

◆ setFieldGrowthPolicy()

void QFormLayout::setFieldGrowthPolicy ( FieldGrowthPolicy  policy)

Definition at line 1974 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFormAlignment()

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

Definition at line 2068 of file qformlayout.cpp.

Here is the call graph for this function:

◆ setGeometry()

void QFormLayout::setGeometry ( const QRect rect)
overridevirtual

\reimp

Reimplemented from QLayout.

Definition at line 1747 of file qformlayout.cpp.

Here is the call graph for this function:

◆ setHorizontalSpacing()

void QFormLayout::setHorizontalSpacing ( int  spacing)

Definition at line 2097 of file qformlayout.cpp.

Here is the call graph for this function:

◆ 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 2293 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLabelAlignment()

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

Definition at line 2038 of file qformlayout.cpp.

Here is the call graph for this function:

◆ 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 2271 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRowWrapPolicy()

void QFormLayout::setRowWrapPolicy ( RowWrapPolicy  policy)

Definition at line 2007 of file qformlayout.cpp.

Here is the call graph for this function:

◆ setSpacing()

void QFormLayout::setSpacing ( int  spacing)
overridevirtual

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

See also
setVerticalSpacing(), setHorizontalSpacing()

Reimplemented from QLayout.

Definition at line 2151 of file qformlayout.cpp.

Here is the call graph for this function:

◆ setVerticalSpacing()

void QFormLayout::setVerticalSpacing ( int  spacing)

Definition at line 2126 of file qformlayout.cpp.

Here is the call graph for this function:

◆ 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 2251 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sizeHint()

QSize QFormLayout::sizeHint ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 1775 of file qformlayout.cpp.

Here is the call graph for this function:

◆ spacing()

int QFormLayout::spacing ( ) const
overridevirtual

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

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

Reimplemented from QLayout.

Definition at line 2164 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ takeAt()

QLayoutItem * QFormLayout::takeAt ( int  index)
overridevirtual

\reimp

Implements QLayout.

Definition at line 1666 of file qformlayout.cpp.

Here is the caller graph for this function:

◆ takeRow() [1/3]

QFormLayout::TakeRowResult QFormLayout::takeRow ( int  row)
Since
5.8

Removes the specified row from this form layout.

row must be non-negative and less than rowCount().

Note
This function doesn't delete anything.

After this call, rowCount() is decremented by one. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows.

You can use this function to undo a previous addRow() or insertRow():

If you want to remove the row from the layout and delete the widgets, use removeRow() instead.

Returns
A structure containing both the widget and corresponding label layout items
See also
removeRow()

Definition at line 1528 of file qformlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ takeRow() [2/3]

QFormLayout::TakeRowResult QFormLayout::takeRow ( QLayout layout)
Since
5.8

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

Removes the specified layout from this form layout.

Note
This function doesn't delete anything.

After this call, rowCount() is decremented by one. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows.

If you want to remove the row from the form layout and delete the inserted layout, use removeRow() instead.

Returns
A structure containing both the widget and corresponding label layout items
See also
removeRow()

Definition at line 1613 of file qformlayout.cpp.

Here is the call graph for this function:

◆ takeRow() [3/3]

QFormLayout::TakeRowResult QFormLayout::takeRow ( QWidget widget)
Since
5.8

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

Removes the specified widget from this form layout.

Note
This function doesn't delete anything.

After this call, rowCount() is decremented by one. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows.

If you want to remove the row from the layout and delete the widgets, use removeRow() instead.

Returns
A structure containing both the widget and corresponding label layout items
See also
removeRow()

Definition at line 1573 of file qformlayout.cpp.

Here is the call graph for this function:

◆ verticalSpacing()

int QFormLayout::verticalSpacing ( ) const

Definition at line 2135 of file qformlayout.cpp.

Here is the call graph for this function:

Property Documentation

◆ fieldGrowthPolicy

QFormLayout::fieldGrowthPolicy
readwrite

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 \l{formAlignment}{form alignment}.

See also
formAlignment, rowWrapPolicy

Definition at line 178 of file qformlayout.h.

◆ formAlignment

QFormLayout::formAlignment
readwrite

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 178 of file qformlayout.h.

◆ horizontalSpacing

QFormLayout::horizontalSpacing
readwrite

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 178 of file qformlayout.h.

◆ labelAlignment

QFormLayout::labelAlignment
readwrite

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 178 of file qformlayout.h.

◆ rowWrapPolicy

QFormLayout::rowWrapPolicy
readwrite

the way in which the form's rows wrap

The default value depends on the widget or application style. For Qt Extended styles, 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 178 of file qformlayout.h.

◆ verticalSpacing

QFormLayout::verticalSpacing
readwrite

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 178 of file qformlayout.h.


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