A simple grid container which rearrange the children based on its size. More...
Classes | |
class | ChildBox |
Description of one child widget in the grid. More... | |
Public Types | |
typedef QWidget | SuperClass |
Reference to superclass. More... | |
Public Member Functions | |
QtlAutoGrid (QWidget *parent=0) | |
Constructor. More... | |
int | bottomMargin () const |
Get the bottom margin in pixels. More... | |
virtual bool | hasHeightForWidth () const Q_DECL_OVERRIDE |
Check if the preferred height of the widget depends on its width. More... | |
virtual int | heightForWidth (int width) const Q_DECL_OVERRIDE |
Compute the widget height for a given width. More... | |
int | horizontalSpacing () const |
Get the horizontal spacing in pixels. More... | |
int | leftMargin () const |
Get the left margin in pixels. More... | |
virtual QSize | minimumSizeHint () const Q_DECL_OVERRIDE |
Return the recommended minimum size for the widget. More... | |
int | rightMargin () const |
Get the right margin in pixels. More... | |
void | setBottomMargin (int bottomMargin) |
Set the bottom margin in pixels. More... | |
void | setHorizontalSpacing (int horizontalSpacing) |
Set the horizontal spacing in pixels. More... | |
void | setLeftMargin (int leftMargin) |
Set the left margin in pixels. More... | |
void | setRightMargin (int rightMargin) |
Set the right margin in pixels. More... | |
void | setTopMargin (int topMargin) |
Set the top margin in pixels. More... | |
void | setVerticalSpacing (int verticalSpacing) |
Set the vertical spacing in pixels. More... | |
virtual QSize | sizeHint () const Q_DECL_OVERRIDE |
Return the widget size hint. More... | |
int | topMargin () const |
Get the top margin in pixels. More... | |
int | verticalSpacing () const |
Get the vertical spacing in pixels. More... | |
Protected Member Functions | |
virtual void | childEvent (QChildEvent *event) Q_DECL_OVERRIDE |
Invoked when a child is added, polished or removed. More... | |
virtual bool | event (QEvent *event) Q_DECL_OVERRIDE |
General event handler. More... | |
virtual void | resizeEvent (QResizeEvent *event) Q_DECL_OVERRIDE |
Invoked when the widget is resized. More... | |
Private Member Functions | |
bool | addNewChild (QWidget *child) |
Register a new child, if not yet known. More... | |
int | columnsForWidth (int width) const |
Compute the number of columns for a given widget width. More... | |
int | columnWidth (int column, int rows) const |
Compute the width of a given column, assuming a given row/column layout. More... | |
void | reorganizeLayout (bool needUpdateGeometry) |
Reorganize the layout of the children widgets. More... | |
int | rowHeight (int row, int rows) const |
Compute the height of a given row, assuming a given row/column layout. More... | |
int | rowsForColumns (int columns) const |
Compute the number of rows for a given number of columns. More... | |
int | widthForColumns (int columns) const |
Compute the widget width for a given number of columns. More... | |
Private Attributes | |
int | _bottomMargin |
Bottom margin in pixels. More... | |
QList< ChildBox > | _children |
List of managed children. More... | |
int | _horizontalSpacing |
Horizontal spacing between pixels. More... | |
int | _leftMargin |
Left margin in pixels. More... | |
int | _rightMargin |
Right margin in pixels. More... | |
int | _topMargin |
Top margin in pixels. More... | |
int | _verticalSpacing |
Vertical spacing between pixels. More... | |
A simple grid container which rearrange the children based on its size.
When the container is resized, the children are rearranged to fill rows first, ie. to occupy the maximum width.
Limitations:
typedef QWidget QtlAutoGrid::SuperClass |
Reference to superclass.
|
explicit |
Constructor.
[in] | parent | Optional parent widget. |
|
inline |
Get the left margin in pixels.
void QtlAutoGrid::setLeftMargin | ( | int | leftMargin | ) |
Set the left margin in pixels.
[in] | leftMargin | The left margin in pixels. |
|
inline |
Get the right margin in pixels.
void QtlAutoGrid::setRightMargin | ( | int | rightMargin | ) |
Set the right margin in pixels.
[in] | rightMargin | The right margin in pixels. |
|
inline |
Get the top margin in pixels.
void QtlAutoGrid::setTopMargin | ( | int | topMargin | ) |
Set the top margin in pixels.
[in] | topMargin | The top margin in pixels. |
|
inline |
Get the bottom margin in pixels.
void QtlAutoGrid::setBottomMargin | ( | int | bottomMargin | ) |
Set the bottom margin in pixels.
[in] | bottomMargin | The bottom margin in pixels. |
|
inline |
Get the horizontal spacing in pixels.
void QtlAutoGrid::setHorizontalSpacing | ( | int | horizontalSpacing | ) |
Set the horizontal spacing in pixels.
[in] | horizontalSpacing | The horizontal spacing in pixels. |
|
inline |
Get the vertical spacing in pixels.
void QtlAutoGrid::setVerticalSpacing | ( | int | verticalSpacing | ) |
Set the vertical spacing in pixels.
[in] | verticalSpacing | The vertical spacing in pixels. |
|
virtual |
Return the recommended minimum size for the widget.
Reimplemented from QWidget.
|
virtual |
Return the widget size hint.
Reimplemented from QWidget.
|
inlinevirtual |
Check if the preferred height of the widget depends on its width.
Reimplemented from QWidget.
|
virtual |
Compute the widget height for a given width.
Reimplemented from QWidget.
[in] | width | The proposed width for the widget. |
|
protectedvirtual |
General event handler.
Reimplemented from QWidget and QObject.
event | Event. |
|
protectedvirtual |
Invoked when a child is added, polished or removed.
Reimplemented from QObject.
[in] | event | The event to intercept. |
Reimplemented in QtlButtonGrid.
|
protectedvirtual |
Invoked when the widget is resized.
Reimplemented from QWidget.
[in] | event | The event to intercept. |
|
private |
Compute the number of columns for a given widget width.
[in] | width | The proposed width for the widget. |
|
private |
Compute the widget width for a given number of columns.
[in] | columns | The proposed number of columns. |
|
private |
Compute the number of rows for a given number of columns.
[in] | columns | The number of columns. |
|
private |
Compute the height of a given row, assuming a given row/column layout.
[in] | row | Index of the row. |
[in] | rows | Number of rows in the grid. |
|
private |
Compute the width of a given column, assuming a given row/column layout.
[in] | column | Index of the column. |
[in] | rows | Number of rows in the grid. |
|
private |
Register a new child, if not yet known.
[in] | child | The child to add. |
|
private |
Reorganize the layout of the children widgets.
[in] | needUpdateGeometry | If true, invoke updateGeometry() even if no widget has been moved. |
|
private |
Left margin in pixels.
|
private |
Right margin in pixels.
|
private |
Top margin in pixels.
|
private |
Bottom margin in pixels.
|
private |
Horizontal spacing between pixels.
|
private |
Vertical spacing between pixels.
|
private |
List of managed children.