QFlowLayout¶
A QLayout that places its items in a
row, left to right, and wraps them onto a new row when there's no more room,
like words in a paragraph. Resizing the widget rearranges them.
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
¶
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:
-
parent(QWidget, default:None) –The parent widget, by default None
Subclass of QLayout
QFlowLayout inherits all of QLayout's methods, signals, and properties. Only those that superqt adds or changes are listed here.
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:
-
parent(QWidget, default:None) –The parent widget, by default None
expandingDirections
¶
Return the expanding directions.
These are the Qt::Orientations in which the layout can make use of more space than its sizeHint().
heightForWidth
¶
Return the height for a given width.
heightForWidth() passes the width on to _doLayout() which in turn uses the
width as an argument for the layout rect, i.e., the bounds in which the items
are laid out. This rect does not include the layout margin().
itemAt
¶
itemAt(index: int) -> QLayoutItem | None
Return the item at the given index, or None if the index is out of range.
setGeometry
¶
Set the geometry of the layout.
This triggers a re-layout of the items.
setHorizontalSpacing
¶
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
¶
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.