Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
FlowWidget Class Reference

#include <flow_widget.h>

Inheritance diagram for FlowWidget:
[legend]
Collaboration diagram for FlowWidget:
[legend]

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

Constructor & Destructor Documentation

◆ FlowWidget()

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.

Parameters
parentParent widget.
_flowDirectionQt::Horizontal for row-wrapping, Qt::Vertical for column-wrapping.
horizontalPolicyHorizontal scroll-bar policy.
verticalPolicyVertical scroll-bar policy.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ addNavigableWidget()

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.

Parameters
widget_to_addThe widget to add to the flow layout.
Here is the caller graph for this function:

◆ addWidget()

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.

Parameters
widget_to_addThe widget to add to the flow layout.
Here is the caller graph for this function:

◆ clearLayout()

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.

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

◆ count()

int FlowWidget::count ( ) const
nodiscard
Here is the call graph for this function:

◆ eventFilter()

bool FlowWidget::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected
Here is the call graph for this function:

◆ insertWidgetAtIndex()

void FlowWidget::insertWidgetAtIndex ( QWidget * toInsert,
int index )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemAt()

QLayoutItem * FlowWidget::itemAt ( int index) const
nodiscard
Here is the call graph for this function:

◆ keyPressEvent()

void FlowWidget::keyPressEvent ( QKeyEvent * event)
overrideprotected
Here is the call graph for this function:

◆ moveFocus()

bool FlowWidget::moveFocus ( QKeyEvent * event)
private

Moves keyboard focus to an adjacent flow item for an arrow-key event.

Returns
True when the event was an arrow key and was handled.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeWidget()

void FlowWidget::removeWidget ( QWidget * widgetToRemove) const
Here is the caller graph for this function:

◆ resizeEvent()

void FlowWidget::resizeEvent ( QResizeEvent * event)
overrideprotected

Marks the flow layout as dirty so Qt recomputes item positions.

We do NOT call adjustSize() or activate() here:

  • adjustSize() would freeze geometry by calling setFixedSize internally.
  • activate() called inside a resize event can cause synchronous re-entrancy. Qt automatically calls setGeometry on the layout after a resize, so simply invalidating is sufficient.

◆ setMinimumSizeToMaxSizeHint

void FlowWidget::setMinimumSizeToMaxSizeHint ( )
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.

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

◆ setSpacing

void FlowWidget::setSpacing ( int hSpacing,
int vSpacing )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ container

QWidget* FlowWidget::container
private

◆ flowDirection

Qt::Orientation FlowWidget::flowDirection
private

◆ flowLayout

FlowLayout* FlowWidget::flowLayout
private

◆ mainLayout

QHBoxLayout* FlowWidget::mainLayout
private

◆ scrollArea

QScrollArea* FlowWidget::scrollArea

Null when both scroll policies are AlwaysOff.


The documentation for this class was generated from the following files:
  • cockatrice/src/interface/widgets/general/layout_containers/flow_widget.h
  • cockatrice/src/interface/widgets/general/layout_containers/flow_widget.cpp