Qt 4.8
|
The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View. More...
#include <qgraphicsgridlayout.h>
Public Functions | |
void | addItem (QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment=0) |
Adds item to the grid on row and column. More... | |
void | addItem (QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment=0) |
Adds item to the grid on row and column. More... | |
Qt::Alignment | alignment (QGraphicsLayoutItem *item) const |
Returns the alignment for item. More... | |
Qt::Alignment | columnAlignment (int column) const |
Returns the alignment for column. More... | |
int | columnCount () const |
Returns the number of columns in the grid layout. More... | |
qreal | columnMaximumWidth (int column) const |
Returns the maximum width for column. More... | |
qreal | columnMinimumWidth (int column) const |
Returns the minimum width for column. More... | |
qreal | columnPreferredWidth (int column) const |
Returns the preferred width for column. More... | |
qreal | columnSpacing (int column) const |
Returns the column spacing for column. More... | |
int | columnStretchFactor (int column) const |
Returns the stretch factor for column. More... | |
int | count () const |
Returns the number of layout items in this grid layout. More... | |
qreal | horizontalSpacing () const |
Returns the default horizontal spacing for the grid layout. More... | |
void | invalidate () |
Reimplemented Function More... | |
QGraphicsLayoutItem * | itemAt (int row, int column) const |
Returns a pointer to the layout item at (row, column). More... | |
QGraphicsLayoutItem * | itemAt (int index) const |
Returns the layout item at index, or 0 if there is no layout item at this index. More... | |
QGraphicsGridLayout (QGraphicsLayoutItem *parent=0) | |
Constructs a QGraphicsGridLayout instance. More... | |
void | removeAt (int index) |
Removes the layout item at index without destroying it. More... | |
void | removeItem (QGraphicsLayoutItem *item) |
Removes the layout item item without destroying it. More... | |
Qt::Alignment | rowAlignment (int row) const |
Returns the alignment of row. More... | |
int | rowCount () const |
Returns the number of rows in the grid layout. More... | |
qreal | rowMaximumHeight (int row) const |
Returns the maximum height for row, row. More... | |
qreal | rowMinimumHeight (int row) const |
Returns the minimum height for row, row. More... | |
qreal | rowPreferredHeight (int row) const |
Returns the preferred height for row, row. More... | |
qreal | rowSpacing (int row) const |
Returns the row spacing for row. More... | |
int | rowStretchFactor (int row) const |
Returns the stretch factor for row. More... | |
void | setAlignment (QGraphicsLayoutItem *item, Qt::Alignment alignment) |
Sets the alignment for item to alignment. More... | |
void | setColumnAlignment (int column, Qt::Alignment alignment) |
Sets the alignment for column to alignment. More... | |
void | setColumnFixedWidth (int column, qreal width) |
Sets the fixed width of column to width. More... | |
void | setColumnMaximumWidth (int column, qreal width) |
Sets the maximum width of column to width. More... | |
void | setColumnMinimumWidth (int column, qreal width) |
Sets the minimum width for column to width. More... | |
void | setColumnPreferredWidth (int column, qreal width) |
Sets the preferred width for column to width. More... | |
void | setColumnSpacing (int column, qreal spacing) |
Sets the spacing for column to spacing. More... | |
void | setColumnStretchFactor (int column, int stretch) |
Sets the stretch factor for column to stretch. More... | |
void | setGeometry (const QRectF &rect) |
Sets the bounding geometry of the grid layout to rect. More... | |
void | setHorizontalSpacing (qreal spacing) |
Sets the default horizontal spacing for the grid layout to spacing. More... | |
void | setRowAlignment (int row, Qt::Alignment alignment) |
Sets the alignment of row to alignment. More... | |
void | setRowFixedHeight (int row, qreal height) |
Sets the fixed height for row, row, to height. More... | |
void | setRowMaximumHeight (int row, qreal height) |
Sets the maximum height for row, row, to height. More... | |
void | setRowMinimumHeight (int row, qreal height) |
Sets the minimum height for row, row, to height. More... | |
void | setRowPreferredHeight (int row, qreal height) |
Sets the preferred height for row, row, to height. More... | |
void | setRowSpacing (int row, qreal spacing) |
Sets the spacing for row to spacing. More... | |
void | setRowStretchFactor (int row, int stretch) |
Sets the stretch factor for row to stretch. More... | |
void | setSpacing (qreal spacing) |
Sets the grid layout's default spacing, both vertical and horizontal, to spacing. More... | |
void | setVerticalSpacing (qreal spacing) |
Sets the default vertical spacing for the grid layout to spacing. More... | |
QSizeF | sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const |
Reimplemented Function More... | |
qreal | verticalSpacing () const |
Returns the default vertical spacing for the grid layout. More... | |
virtual | ~QGraphicsGridLayout () |
Destroys the QGraphicsGridLayout object. More... | |
Public Functions inherited from QGraphicsLayout | |
void | activate () |
Activates the layout, causing all items in the layout to be immediately rearranged. More... | |
void | getContentsMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const |
Reimplemented Function More... | |
bool | isActivated () const |
Returns true if the layout is currently being activated; otherwise, returns false. More... | |
QGraphicsLayout (QGraphicsLayoutItem *parent=0) | |
Contructs a QGraphicsLayout object. More... | |
void | setContentsMargins (qreal left, qreal top, qreal right, qreal bottom) |
Sets the contents margins to left, top, right and bottom. More... | |
virtual void | updateGeometry () |
Reimplemented Function More... | |
virtual void | widgetEvent (QEvent *e) |
This virtual event handler receives all events for the managed widget. More... | |
~QGraphicsLayout () | |
Destroys the QGraphicsLayout object. More... | |
Public Functions inherited from QGraphicsLayoutItem | |
QRectF | contentsRect () const |
Returns the contents rect in local coordinates. More... | |
QSizeF | effectiveSizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const |
Returns the effective size hint for this QGraphicsLayoutItem. More... | |
QRectF | geometry () const |
Returns the item's geometry (e. More... | |
QGraphicsItem * | graphicsItem () const |
Returns the QGraphicsItem that this layout item represents. More... | |
bool | isLayout () const |
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false. More... | |
qreal | maximumHeight () const |
Returns the maximum height. More... | |
QSizeF | maximumSize () const |
Returns the maximum size. More... | |
qreal | maximumWidth () const |
Returns the maximum width. More... | |
qreal | minimumHeight () const |
Returns the minimum height. More... | |
QSizeF | minimumSize () const |
Returns the minimum size. More... | |
qreal | minimumWidth () const |
Returns the minimum width. More... | |
bool | ownedByLayout () const |
Returns whether a layout should delete this item in its destructor. More... | |
QGraphicsLayoutItem * | parentLayoutItem () const |
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes). More... | |
qreal | preferredHeight () const |
Returns the preferred height. More... | |
QSizeF | preferredSize () const |
Returns the preferred size. More... | |
qreal | preferredWidth () const |
Returns the preferred width. More... | |
QGraphicsLayoutItem (QGraphicsLayoutItem *parent=0, bool isLayout=false) | |
Constructs the QGraphicsLayoutItem object. More... | |
void | setMaximumHeight (qreal height) |
Sets the maximum height to height. More... | |
void | setMaximumSize (const QSizeF &size) |
Sets the maximum size to size. More... | |
void | setMaximumSize (qreal w, qreal h) |
This convenience function is equivalent to calling setMaximumSize(QSizeF(w, h)). More... | |
void | setMaximumWidth (qreal width) |
Sets the maximum width to width. More... | |
void | setMinimumHeight (qreal height) |
Sets the minimum height to height. More... | |
void | setMinimumSize (const QSizeF &size) |
Sets the minimum size to size. More... | |
void | setMinimumSize (qreal w, qreal h) |
This convenience function is equivalent to calling setMinimumSize(QSizeF(w, h)). More... | |
void | setMinimumWidth (qreal width) |
Sets the minimum width to width. More... | |
void | setParentLayoutItem (QGraphicsLayoutItem *parent) |
Sets the parent of this QGraphicsLayoutItem to parent. More... | |
void | setPreferredHeight (qreal height) |
Sets the preferred height to height. More... | |
void | setPreferredSize (const QSizeF &size) |
Sets the preferred size to size. More... | |
void | setPreferredSize (qreal w, qreal h) |
This convenience function is equivalent to calling setPreferredSize(QSizeF(w, h)). More... | |
void | setPreferredWidth (qreal width) |
Sets the preferred width to width. More... | |
void | setSizePolicy (const QSizePolicy &policy) |
Sets the size policy to policy. More... | |
void | setSizePolicy (QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType=QSizePolicy::DefaultType) |
This function is equivalent to calling setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)). More... | |
QSizePolicy | sizePolicy () const |
Returns the current size policy. More... | |
virtual | ~QGraphicsLayoutItem () |
Destroys the QGraphicsLayoutItem object. More... | |
Additional Inherited Members | |
Static Public Functions inherited from QGraphicsLayout | |
static bool | instantInvalidatePropagation () |
static void | setInstantInvalidatePropagation (bool enable) |
Protected Functions inherited from QGraphicsLayout | |
void | addChildLayoutItem (QGraphicsLayoutItem *layoutItem) |
This function is a convenience function provided for custom layouts, and will go through all items in the layout and reparent their graphics items to the closest QGraphicsWidget ancestor of the layout. More... | |
QGraphicsLayout (QGraphicsLayoutPrivate &, QGraphicsLayoutItem *) | |
Protected Functions inherited from QGraphicsLayoutItem | |
QGraphicsLayoutItem (QGraphicsLayoutItemPrivate &dd) | |
void | setGraphicsItem (QGraphicsItem *item) |
If the QGraphicsLayoutItem represents a QGraphicsItem, and it wants to take advantage of the automatic reparenting capabilities of QGraphicsLayout it should set this value. More... | |
void | setOwnedByLayout (bool ownedByLayout) |
Sets whether a layout should delete this item in its destructor or not. More... | |
Protected Variables inherited from QGraphicsLayoutItem | |
QScopedPointer< QGraphicsLayoutItemPrivate > | d_ptr |
The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View.
The most common way to use QGraphicsGridLayout is to construct an object on the heap with no parent, add widgets and layouts by calling addItem(), and finally assign the layout to a widget by calling QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes the dimensions of the grid as you add items.
The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle this. You can access each item in the layout by calling count() and itemAt(). Calling removeAt() will remove an item from the layout, without destroying it.
QGraphicsGridLayout respects each item's size hints and size policies, and when a cell in the grid has more space than the items can fill, each item is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling setAlignment(), and check the alignment for any item by calling alignment(). You can also set the alignment for an entire row or column by calling setRowAlignment() and setColumnAlignment() respectively. By default, items are aligned to the top left.
Definition at line 58 of file qgraphicsgridlayout.h.
QGraphicsGridLayout::QGraphicsGridLayout | ( | QGraphicsLayoutItem * | parent = 0 | ) |
Constructs a QGraphicsGridLayout instance.
parent is passed to QGraphicsLayout's constructor.
Definition at line 124 of file qgraphicsgridlayout.cpp.
|
virtual |
Destroys the QGraphicsGridLayout object.
Definition at line 132 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::addItem | ( | QGraphicsLayoutItem * | item, |
int | row, | ||
int | column, | ||
int | rowSpan, | ||
int | columnSpan, | ||
Qt::Alignment | alignment = 0 |
||
) |
Adds item to the grid on row and column.
You can specify a rowSpan and columnSpan and an optional alignment.
Definition at line 152 of file qgraphicsgridlayout.cpp.
|
inline |
Adds item to the grid on row and column.
You can specify an optional alignment for item.
Definition at line 134 of file qgraphicsgridlayout.h.
Qt::Alignment QGraphicsGridLayout::alignment | ( | QGraphicsLayoutItem * | item | ) | const |
Returns the alignment for item.
Definition at line 502 of file qgraphicsgridlayout.cpp.
Qt::Alignment QGraphicsGridLayout::columnAlignment | ( | int | column | ) | const |
Returns the alignment for column.
Definition at line 483 of file qgraphicsgridlayout.cpp.
int QGraphicsGridLayout::columnCount | ( | ) | const |
Returns the number of columns in the grid layout.
This is always one more than the index of the last column that is occupied by a layout item (empty columns are counted except for those at the end).
Definition at line 524 of file qgraphicsgridlayout.cpp.
Referenced by itemAt().
qreal QGraphicsGridLayout::columnMaximumWidth | ( | int | column | ) | const |
Returns the maximum width for column.
Definition at line 434 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::columnMinimumWidth | ( | int | column | ) | const |
Returns the minimum width for column.
Definition at line 396 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::columnPreferredWidth | ( | int | column | ) | const |
Returns the preferred width for column.
Definition at line 415 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::columnSpacing | ( | int | column | ) | const |
Returns the column spacing for column.
Definition at line 271 of file qgraphicsgridlayout.cpp.
int QGraphicsGridLayout::columnStretchFactor | ( | int | column | ) | const |
Returns the stretch factor for column.
Definition at line 309 of file qgraphicsgridlayout.cpp.
|
virtual |
Returns the number of layout items in this grid layout.
Implements QGraphicsLayout.
Definition at line 548 of file qgraphicsgridlayout.cpp.
Referenced by ~QGraphicsGridLayout().
qreal QGraphicsGridLayout::horizontalSpacing | ( | ) | const |
Returns the default horizontal spacing for the grid layout.
Definition at line 201 of file qgraphicsgridlayout.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QGraphicsLayout.
Definition at line 625 of file qgraphicsgridlayout.cpp.
Referenced by addItem(), removeAt(), setAlignment(), setColumnAlignment(), setColumnFixedWidth(), setColumnMaximumWidth(), setColumnMinimumWidth(), setColumnPreferredWidth(), setColumnSpacing(), setColumnStretchFactor(), setHorizontalSpacing(), setRowAlignment(), setRowFixedHeight(), setRowMaximumHeight(), setRowMinimumHeight(), setRowPreferredHeight(), setRowSpacing(), setRowStretchFactor(), setSpacing(), and setVerticalSpacing().
QGraphicsLayoutItem * QGraphicsGridLayout::itemAt | ( | int | row, |
int | column | ||
) | const |
Returns a pointer to the layout item at (row, column).
Definition at line 533 of file qgraphicsgridlayout.cpp.
Referenced by ~QGraphicsGridLayout().
|
virtual |
Returns the layout item at index, or 0 if there is no layout item at this index.
Implements QGraphicsLayout.
Definition at line 558 of file qgraphicsgridlayout.cpp.
|
virtual |
Removes the layout item at index without destroying it.
Ownership of the item is transferred to the caller.
Implements QGraphicsLayout.
Definition at line 577 of file qgraphicsgridlayout.cpp.
Referenced by removeItem(), and ~QGraphicsGridLayout().
void QGraphicsGridLayout::removeItem | ( | QGraphicsLayoutItem * | item | ) |
Removes the layout item item without destroying it.
Ownership of the item is transferred to the caller.
Definition at line 616 of file qgraphicsgridlayout.cpp.
Qt::Alignment QGraphicsGridLayout::rowAlignment | ( | int | row | ) | const |
Returns the alignment of row.
Definition at line 464 of file qgraphicsgridlayout.cpp.
int QGraphicsGridLayout::rowCount | ( | ) | const |
Returns the number of rows in the grid layout.
This is always one more than the index of the last row that is occupied by a layout item (empty rows are counted except for those at the end).
Definition at line 513 of file qgraphicsgridlayout.cpp.
Referenced by itemAt().
qreal QGraphicsGridLayout::rowMaximumHeight | ( | int | row | ) | const |
Returns the maximum height for row, row.
Definition at line 366 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::rowMinimumHeight | ( | int | row | ) | const |
Returns the minimum height for row, row.
Definition at line 328 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::rowPreferredHeight | ( | int | row | ) | const |
Returns the preferred height for row, row.
Definition at line 347 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::rowSpacing | ( | int | row | ) | const |
Returns the row spacing for row.
Definition at line 252 of file qgraphicsgridlayout.cpp.
int QGraphicsGridLayout::rowStretchFactor | ( | int | row | ) | const |
Returns the stretch factor for row.
Definition at line 290 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setAlignment | ( | QGraphicsLayoutItem * | item, |
Qt::Alignment | alignment | ||
) |
Sets the alignment for item to alignment.
Definition at line 492 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnAlignment | ( | int | column, |
Qt::Alignment | alignment | ||
) |
Sets the alignment for column to alignment.
Definition at line 473 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnFixedWidth | ( | int | column, |
qreal | width | ||
) |
Sets the fixed width of column to width.
Definition at line 443 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnMaximumWidth | ( | int | column, |
qreal | width | ||
) |
Sets the maximum width of column to width.
Definition at line 424 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnMinimumWidth | ( | int | column, |
qreal | width | ||
) |
Sets the minimum width for column to width.
Definition at line 386 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnPreferredWidth | ( | int | column, |
qreal | width | ||
) |
Sets the preferred width for column to width.
Definition at line 405 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnSpacing | ( | int | column, |
qreal | spacing | ||
) |
Sets the spacing for column to spacing.
Definition at line 261 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setColumnStretchFactor | ( | int | column, |
int | stretch | ||
) |
Sets the stretch factor for column to stretch.
Definition at line 299 of file qgraphicsgridlayout.cpp.
|
virtual |
Sets the bounding geometry of the grid layout to rect.
Reimplemented from QGraphicsLayoutItem.
Definition at line 644 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setHorizontalSpacing | ( | qreal | spacing | ) |
Sets the default horizontal spacing for the grid layout to spacing.
Definition at line 191 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowAlignment | ( | int | row, |
Qt::Alignment | alignment | ||
) |
Sets the alignment of row to alignment.
Definition at line 454 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowFixedHeight | ( | int | row, |
qreal | height | ||
) |
Sets the fixed height for row, row, to height.
Definition at line 375 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowMaximumHeight | ( | int | row, |
qreal | height | ||
) |
Sets the maximum height for row, row, to height.
Definition at line 356 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowMinimumHeight | ( | int | row, |
qreal | height | ||
) |
Sets the minimum height for row, row, to height.
Definition at line 318 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowPreferredHeight | ( | int | row, |
qreal | height | ||
) |
Sets the preferred height for row, row, to height.
Definition at line 337 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowSpacing | ( | int | row, |
qreal | spacing | ||
) |
Sets the spacing for row to spacing.
Definition at line 242 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setRowStretchFactor | ( | int | row, |
int | stretch | ||
) |
Sets the stretch factor for row to stretch.
Definition at line 280 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setSpacing | ( | qreal | spacing | ) |
Sets the grid layout's default spacing, both vertical and horizontal, to spacing.
Definition at line 232 of file qgraphicsgridlayout.cpp.
void QGraphicsGridLayout::setVerticalSpacing | ( | qreal | spacing | ) |
Sets the default vertical spacing for the grid layout to spacing.
Definition at line 210 of file qgraphicsgridlayout.cpp.
|
virtual |
Reimplemented Function
Implements QGraphicsLayoutItem.
Definition at line 670 of file qgraphicsgridlayout.cpp.
qreal QGraphicsGridLayout::verticalSpacing | ( | ) | const |
Returns the default vertical spacing for the grid layout.
Definition at line 220 of file qgraphicsgridlayout.cpp.