Layouting::Layout Class

class Layouting::Layout

Base class for layout builder classes. More...

Header: #include <Layout>
Inherits: Layouting::Object
Inherited By:

Layouting::Column, Layouting::Flow, Layouting::Form, Layouting::Grid, and Layouting::Row

Public Functions

void addItem(Layouting::Layout::I item)
void addItems(std::initializer_list<Layouting::Layout::I> items)
void addRow(std::initializer_list<Layouting::Layout::I> items)
void align(Qt::Alignment alignment)
void attachTo(QWidget *widget)
QWidget *emerge() const
void flush()
void setNoMargins()
void setNormalMargins()
void span(int cols, int rows)

Detailed Description

Wraps a QLayout-derived object. Instances are ephemeral: construct, configure, and call attachTo() or emerge(). Do not store them beyond the enclosing function.

Subclasses accumulate items via addItem(), addItems(), and addRow(), which are flushed into the underlying QLayout when the builder is finalized. For layouts that support rows and spans (Form, Grid), items are staged and committed to the layout by flush().

See also Layouting::Widget, Layouting::Column, Layouting::Row, Layouting::Form, and Layouting::Grid.

Member Function Documentation

void Layout::addItem(Layouting::Layout::I item)

Adds the layout item item as a sub item.

void Layout::addItems(std::initializer_list<Layouting::Layout::I> items)

Adds the layout items items as sub items.

void Layout::addRow(std::initializer_list<Layouting::Layout::I> items)

Starts a new row containing items. The row can be further extended by other items using addItem() or addItems().

See also addItem() and addItems().

void Layout::align(Qt::Alignment alignment)

Sets the alignment to alignment on the last item that was added to this layout. Only meaningful for Grid and Form layouts.

void Layout::attachTo(QWidget *widget)

Attaches the constructed layout to the provided QWidget widget.

This operation can only be performed once per LayoutBuilder instance.

QWidget *Layout::emerge() const

Finalizes the layout and returns it wrapped in a new QWidget.

This is useful when a layout needs to be embedded as a widget (for example inside a QScrollArea or a QStackedWidget) without an explicit outer Widget builder. The caller takes ownership of the returned widget.

See also Layout::attachTo().

void Layout::flush()

Commits all accumulated pending items into the underlying QLayout.

For Grid layouts each call to flush() advances to the next row. For Form layouts each flush() call adds one label-field row (or a single full-width row). For box and flow layouts items are added directly and flush() is a no-op.

flush() is called automatically at the end of a constructor that accepts an initializer list, and by attachTo() and emerge(). Call it manually only when building a layout step by step with addItem() or addRow().

See also Layout::attachTo() and Layout::emerge().

void Layout::setNoMargins()

Sets all four content margins to zero.

See also Layout::setNormalMargins() and Layouting::noMargin.

void Layout::setNormalMargins()

Sets all four content margins to 9 pixels.

See also Layout::setNoMargins() and Layouting::normalMargin.

void Layout::span(int cols, int rows)

Sets the column span to cols and the row span to rows on the last item that was added to this layout. Only meaningful for Grid layouts.

See also Layouting::Span and Layouting::SpanAll.