![]() |
Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
|
#include <flow_widget.h>
Public Slots | |
| void | setMinimumSizeToMaxSizeHint () |
| Sets every child widget's minimum size to the largest sizeHint in the layout. | |
| void | setSpacing (int hSpacing, int vSpacing) |
Public Member Functions | |
| FlowWidget (QWidget *parent, Qt::Orientation orientation, Qt::ScrollBarPolicy horizontalPolicy, Qt::ScrollBarPolicy verticalPolicy) | |
| Constructs a FlowWidget. | |
| void | addWidget (QWidget *widget_to_add) |
| Adds a widget to the flow layout within the FlowWidget. | |
| void | addNavigableWidget (QWidget *widget_to_add) |
| Adds a widget and routes its arrow keys to FlowWidget focus navigation. | |
| void | insertWidgetAtIndex (QWidget *toInsert, int index) |
| void | removeWidget (QWidget *widgetToRemove) const |
| void | clearLayout () |
| Removes all widgets from the flow layout and deletes them. | |
| int | count () const |
| QLayoutItem * | itemAt (int index) const |
Public Attributes | |
| QScrollArea * | scrollArea |
| Null when both scroll policies are AlwaysOff. | |
Protected Member Functions | |
| bool | eventFilter (QObject *watched, QEvent *event) override |
| void | resizeEvent (QResizeEvent *event) override |
| Marks the flow layout as dirty so Qt recomputes item positions. | |
| void | keyPressEvent (QKeyEvent *event) override |
Private Member Functions | |
| bool | moveFocus (QKeyEvent *event) |
| Moves keyboard focus to an adjacent flow item for an arrow-key event. | |
Private Attributes | |
| Qt::Orientation | flowDirection |
| QHBoxLayout * | mainLayout |
| FlowLayout * | flowLayout |
| QWidget * | container |
| FlowWidget::FlowWidget | ( | QWidget * | parent, |
| Qt::Orientation | orientation, | ||
| Qt::ScrollBarPolicy | horizontalPolicy, | ||
| Qt::ScrollBarPolicy | verticalPolicy ) |
Constructs a FlowWidget.
When both scroll policies are Qt::ScrollBarAlwaysOff the scroll area is omitted entirely and the container is placed directly in the main layout.
| parent | Parent widget. |
| _flowDirection | Qt::Horizontal for row-wrapping, Qt::Vertical for column-wrapping. |
| horizontalPolicy | Horizontal scroll-bar policy. |
| verticalPolicy | Vertical scroll-bar policy. |
| void FlowWidget::addNavigableWidget | ( | QWidget * | widget_to_add | ) |
Adds a widget and routes its arrow keys to FlowWidget focus navigation.
The widget is filtered for arrow-key events so keyboard navigation between the flow items keeps working even when the flow sits inside a QScrollArea, which swallows arrow keys before they can reach FlowWidget::keyPressEvent. Only widgets added through this method are affected; anything that needs its own arrow keys should use plain addWidget.
| widget_to_add | The widget to add to the flow layout. |
| void FlowWidget::addWidget | ( | QWidget * | widget_to_add | ) |
Adds a widget to the flow layout within the FlowWidget.
Plain widgets are not filtered for arrow keys: intercepting them would steal Up/Down/Left/Right from controls that use them (combo boxes, spin boxes etc.). Widgets that want keyboard navigation between flow items must be added via addNavigableWidget instead.
| widget_to_add | The widget to add to the flow layout. |
| void FlowWidget::clearLayout | ( | ) |
Removes all widgets from the flow layout and deletes them.
If the layout pointer has somehow been lost it is recreated before returning.
|
nodiscard |
|
overrideprotected |
| void FlowWidget::insertWidgetAtIndex | ( | QWidget * | toInsert, |
| int | index ) |
|
nodiscard |
|
overrideprotected |
|
private |
Moves keyboard focus to an adjacent flow item for an arrow-key event.
| void FlowWidget::removeWidget | ( | QWidget * | widgetToRemove | ) | const |
|
overrideprotected |
Marks the flow layout as dirty so Qt recomputes item positions.
We do NOT call adjustSize() or activate() here:
|
slot |
Sets every child widget's minimum size to the largest sizeHint in the layout.
Useful for toolbars or button bars where all items should be the same size.
|
slot |
|
private |
|
private |
|
private |
|
private |
| QScrollArea* FlowWidget::scrollArea |
Null when both scroll policies are AlwaysOff.