Skip to content

QFlowLayout#

QLayout that rearranges items based on parent width.

from qtpy.QtWidgets import QApplication, QPushButton, QWidget

from superqt import QFlowLayout

app = QApplication([])

wdg = QWidget()

layout = QFlowLayout(wdg)
layout.addWidget(QPushButton("Short"))
layout.addWidget(QPushButton("Longer"))
layout.addWidget(QPushButton("Different text"))
layout.addWidget(QPushButton("More text"))
layout.addWidget(QPushButton("Even longer button text"))

wdg.setWindowTitle("Flow Layout")
wdg.show()

app.exec()

QFlowLayout

Qt Class#

QLayout

Methods#

Layout that handles different window sizes.

The widget placement changes depending on the width of the application window.

Code translated from C++ at: https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/layouts/flowlayout

described at: https://doc.qt.io/qt-6/qtwidgets-layouts-flowlayout-example.html

See also: https://doc.qt.io/qt-6/layout.html

Parameters:

Name Type Description Default
parent QWidget

The parent widget, by default None

None

horizontalSpacing() -> int #

Return the horizontal spacing.

setHorizontalSpacing(space: int | None) -> None #

Set the horizontal spacing.

If None or -1, the spacing is set to the default value based on the style of the parent widget.

setVerticalSpacing(space: int | None) -> None #

Set the vertical spacing.

If None or -1, the spacing is set to the default value based on the style of the parent widget.

verticalSpacing() -> int #

Return the vertical spacing.