A widget for managing overlapping child widgets.
More...
#include <overlap_widget.h>
|
| void | maxOverlapItemsChanged (int newValue) |
| | Updates the maximum number of overlapping items based on new value.
|
| void | overlapDirectionChanged (const QString &newDirection) |
| | Changes the layout direction based on the specified new direction.
|
|
| void | resizeEvent (QResizeEvent *event) override |
| | Handles resizing events for the widget.
|
A widget for managing overlapping child widgets.
The OverlapWidget class is a QWidget subclass that utilizes the OverlapLayout to arrange its child widgets in an overlapping manner. This widget allows configuration of overlap percentage, maximum columns, maximum rows, and layout direction, making it suitable for displaying elements that can partially stack over each other. The widget automatically manages resizing and re-layout of its child widgets based on the available space and specified parameters.
◆ OverlapWidget()
| OverlapWidget::OverlapWidget |
( |
QWidget * | parent, |
|
|
int | overlapPercentage, |
|
|
int | maxColumns, |
|
|
int | maxRows, |
|
|
Qt::Orientation | direction, |
|
|
bool | adjustOnResize = false ) |
Constructs an OverlapWidget with specified layout parameters.
Initializes the OverlapWidget with the given overlap percentage, maximum number of columns and rows, and layout direction. Sets size policies to ensure the widget can expand as needed. A new OverlapLayout is created and assigned to manage the layout of child widgets.
- Parameters
-
| overlapPercentage | The percentage of overlap between child widgets (0-100). |
| maxColumns | The maximum number of columns for the layout (0 for unlimited). |
| maxRows | The maximum number of rows for the layout (0 for unlimited). |
| direction | The orientation of the layout, either Qt::Horizontal or Qt::Vertical. |
| adjustOnResize | If the overlap widgets should adjust its max columns/rows on resize to fit. |
| parent | The parent widget of this OverlapWidget. |
◆ addWidget()
| void OverlapWidget::addWidget |
( |
QWidget * | widgetToAdd | ) |
const |
Adds a widget to the overlap layout.
This method appends the specified widget to the internal OverlapLayout, allowing it to be arranged with the existing child widgets. The widget's visibility and behavior will be managed by the layout.
- Parameters
-
| widgetToAdd | A pointer to the QWidget to be added to the layout. |
◆ adjustMaxColumnsAndRows()
| void OverlapWidget::adjustMaxColumnsAndRows |
( |
| ) |
|
Dynamically adjusts maxColumns and maxRows based on widget size and layout direction.
This function calculates the maximum number of columns or rows that can fit within the widget's width and height, depending on the layout direction. It then updates the OverlapLayout with these calculated values to ensure the layout is optimized.
◆ clearLayout()
| void OverlapWidget::clearLayout |
( |
| ) |
|
Clears all widgets from the layout and deletes them.
This method removes all child widgets from the OverlapLayout, deleting both the widget instances and their corresponding layout items. This ensures that the layout is empty and can be reused or refreshed as needed.
◆ insertWidgetAtIndex()
| void OverlapWidget::insertWidgetAtIndex |
( |
QWidget * | toInsert, |
|
|
int | index ) |
◆ maxOverlapItemsChanged
| void OverlapWidget::maxOverlapItemsChanged |
( |
int | newValue | ) |
|
|
slot |
Updates the maximum number of overlapping items based on new value.
This method updates the maximum number of columns or rows for the overlap layout based on the given new value. It adjusts the layout direction accordingly and triggers a size adjustment for the widget, ensuring the layout reflects the changes.
- Parameters
-
| newValue | The new maximum number of overlapping items allowed in the layout. |
◆ overlapDirectionChanged
| void OverlapWidget::overlapDirectionChanged |
( |
const QString & | newDirection | ) |
|
|
slot |
Changes the layout direction based on the specified new direction.
This method modifies the layout direction of the OverlapLayout based on the input string. It updates the direction and triggers a size adjustment for the widget. Valid inputs are "Qt::Horizontal" and "Qt::Vertical".
- Parameters
-
| newDirection | The new layout direction as a QString. |
◆ removeWidget()
| void OverlapWidget::removeWidget |
( |
QWidget * | widgetToRemove | ) |
const |
◆ resizeEvent()
| void OverlapWidget::resizeEvent |
( |
QResizeEvent * | event | ) |
|
|
overrideprotected |
Handles resizing events for the widget.
This overridden method is called when the widget is resized. It invokes layout recalculation to ensure that the child widgets are correctly arranged based on the new dimensions. It marks the layout as dirty and activates it to reflect the changes.
- Parameters
-
| event | The resize event containing the new size information. |
◆ adjustOnResize
| bool OverlapWidget::adjustOnResize = false |
|
private |
◆ direction
| Qt::Orientation OverlapWidget::direction |
|
private |
◆ maxColumns
| int OverlapWidget::maxColumns |
|
private |
◆ maxRows
| int OverlapWidget::maxRows |
|
private |
◆ overlapLayout
◆ overlapPercentage
| int OverlapWidget::overlapPercentage |
|
private |
The documentation for this class was generated from the following files: