Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QGraphicsGridLayout Class

TheQGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View.More...

Header:#include <QGraphicsGridLayout>
Since: Qt 4.4
Inherits:QGraphicsLayout

Public Functions

QGraphicsGridLayout(QGraphicsLayoutItem * parent = 0)
virtual~QGraphicsGridLayout()
voidaddItem(QGraphicsLayoutItem * item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = 0)
voidaddItem(QGraphicsLayoutItem * item, int row, int column, Qt::Alignment alignment = 0)
Qt::Alignmentalignment(QGraphicsLayoutItem * item) const
Qt::AlignmentcolumnAlignment(int column) const
intcolumnCount() const
qrealcolumnMaximumWidth(int column) const
qrealcolumnMinimumWidth(int column) const
qrealcolumnPreferredWidth(int column) const
qrealcolumnSpacing(int column) const
intcolumnStretchFactor(int column) const
qrealhorizontalSpacing() const
QGraphicsLayoutItem *itemAt(int row, int column) const
voidremoveItem(QGraphicsLayoutItem * item)
Qt::AlignmentrowAlignment(int row) const
introwCount() const
qrealrowMaximumHeight(int row) const
qrealrowMinimumHeight(int row) const
qrealrowPreferredHeight(int row) const
qrealrowSpacing(int row) const
introwStretchFactor(int row) const
voidsetAlignment(QGraphicsLayoutItem * item, Qt::Alignment alignment)
voidsetColumnAlignment(int column, Qt::Alignment alignment)
voidsetColumnFixedWidth(int column, qreal width)
voidsetColumnMaximumWidth(int column, qreal width)
voidsetColumnMinimumWidth(int column, qreal width)
voidsetColumnPreferredWidth(int column, qreal width)
voidsetColumnSpacing(int column, qreal spacing)
voidsetColumnStretchFactor(int column, int stretch)
voidsetHorizontalSpacing(qreal spacing)
voidsetRowAlignment(int row, Qt::Alignment alignment)
voidsetRowFixedHeight(int row, qreal height)
voidsetRowMaximumHeight(int row, qreal height)
voidsetRowMinimumHeight(int row, qreal height)
voidsetRowPreferredHeight(int row, qreal height)
voidsetRowSpacing(int row, qreal spacing)
voidsetRowStretchFactor(int row, int stretch)
voidsetSpacing(qreal spacing)
voidsetVerticalSpacing(qreal spacing)
qrealverticalSpacing() const

Reimplemented Public Functions

virtual intcount() const
virtual voidinvalidate()
virtual QGraphicsLayoutItem *itemAt(int index) const
virtual voidremoveAt(int index)
virtual voidsetGeometry(const QRectF & rect)
virtual QSizeFsizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const

Additional Inherited Members

Detailed Description

TheQGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View.

The most common way to useQGraphicsGridLayout is to construct an object on the heap with no parent, add widgets and layouts by callingaddItem(), and finally assign the layout to a widget by callingQGraphicsWidget::setLayout().QGraphicsGridLayout automatically computes the dimensions of the grid as you add items.

QGraphicsScene scene;QGraphicsWidget*textEdit= scene.addWidget(newQTextEdit);QGraphicsWidget*pushButton= scene.addWidget(newQPushButton);QGraphicsGridLayout*layout=newQGraphicsGridLayout;layout->addItem(textEdit,0,0);layout->addItem(pushButton,0,1);QGraphicsWidget*form=newQGraphicsWidget;form->setLayout(layout);scene.addItem(form);

The layout takes ownership of the items. In some cases when the layout item also inherits fromQGraphicsItem (such asQGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation ofQGraphicsLayoutItem::setOwnedByLayout() how to handle this. You can access each item in the layout by callingcount() anditemAt(). CallingremoveAt() will remove an item from the layout, without destroying it.

Size Hints and Size Policies in QGraphicsGridLayout

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 callingsetAlignment(), and check the alignment for any item by callingalignment(). You can also set the alignment for an entire row or column by callingsetRowAlignment() andsetColumnAlignment() respectively. By default, items are aligned to the top left.

See alsoQGraphicsLinearLayout andQGraphicsWidget.

Member Function Documentation

QGraphicsGridLayout::QGraphicsGridLayout(QGraphicsLayoutItem * parent = 0)

Constructs aQGraphicsGridLayout instance.parent is passed toQGraphicsLayout's constructor.

[virtual]QGraphicsGridLayout::~QGraphicsGridLayout()

Destroys theQGraphicsGridLayout object.

void QGraphicsGridLayout::addItem(QGraphicsLayoutItem * item,int row,int column,int rowSpan,int columnSpan,Qt::Alignment alignment = 0)

Addsitem to the grid onrow andcolumn. You can specify arowSpan andcolumnSpan and an optionalalignment.

void QGraphicsGridLayout::addItem(QGraphicsLayoutItem * item,int row,int column,Qt::Alignment alignment = 0)

Addsitem to the grid onrow andcolumn. You can specify an optionalalignment foritem.

Qt::Alignment QGraphicsGridLayout::alignment(QGraphicsLayoutItem * item) const

Returns the alignment foritem.

See alsosetAlignment().

Qt::Alignment QGraphicsGridLayout::columnAlignment(int column) const

Returns the alignment forcolumn.

See alsosetColumnAlignment().

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).

qreal QGraphicsGridLayout::columnMaximumWidth(int column) const

Returns the maximum width forcolumn.

See alsosetColumnMaximumWidth().

qreal QGraphicsGridLayout::columnMinimumWidth(int column) const

Returns the minimum width forcolumn.

See alsosetColumnMinimumWidth().

qreal QGraphicsGridLayout::columnPreferredWidth(int column) const

Returns the preferred width forcolumn.

See alsosetColumnPreferredWidth().

qreal QGraphicsGridLayout::columnSpacing(int column) const

Returns the column spacing forcolumn.

See alsosetColumnSpacing().

int QGraphicsGridLayout::columnStretchFactor(int column) const

Returns the stretch factor forcolumn.

See alsosetColumnStretchFactor().

[virtual]int QGraphicsGridLayout::count() const

Reimplemented fromQGraphicsLayout::count().

Returns the number of layout items in this grid layout.

qreal QGraphicsGridLayout::horizontalSpacing() const

Returns the default horizontal spacing for the grid layout.

See alsosetHorizontalSpacing().

[virtual]void QGraphicsGridLayout::invalidate()

Reimplemented fromQGraphicsLayout::invalidate().

QGraphicsLayoutItem * QGraphicsGridLayout::itemAt(int row,int column) const

Returns a pointer to the layout item at (row,column).

[virtual]QGraphicsLayoutItem * QGraphicsGridLayout::itemAt(int index) const

Reimplemented fromQGraphicsLayout::itemAt().

Returns the layout item atindex, or 0 if there is no layout item at this index.

[virtual]void QGraphicsGridLayout::removeAt(int index)

Reimplemented fromQGraphicsLayout::removeAt().

Removes the layout item atindex without destroying it. Ownership of the item is transferred to the caller.

See alsoaddItem().

void QGraphicsGridLayout::removeItem(QGraphicsLayoutItem * item)

Removes the layout itemitem without destroying it. Ownership of the item is transferred to the caller.

This function was introduced in Qt 4.8.

See alsoaddItem().

Qt::Alignment QGraphicsGridLayout::rowAlignment(int row) const

Returns the alignment ofrow.

See alsosetRowAlignment().

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).

qreal QGraphicsGridLayout::rowMaximumHeight(int row) const

Returns the maximum height for row,row.

See alsosetRowMaximumHeight().

qreal QGraphicsGridLayout::rowMinimumHeight(int row) const

Returns the minimum height for row,row.

See alsosetRowMinimumHeight().

qreal QGraphicsGridLayout::rowPreferredHeight(int row) const

Returns the preferred height for row,row.

See alsosetRowPreferredHeight().

qreal QGraphicsGridLayout::rowSpacing(int row) const

Returns the row spacing forrow.

See alsosetRowSpacing().

int QGraphicsGridLayout::rowStretchFactor(int row) const

Returns the stretch factor forrow.

See alsosetRowStretchFactor().

void QGraphicsGridLayout::setAlignment(QGraphicsLayoutItem * item,Qt::Alignment alignment)

Sets the alignment foritem toalignment.

See alsoalignment().

void QGraphicsGridLayout::setColumnAlignment(int column,Qt::Alignment alignment)

Sets the alignment forcolumn toalignment.

See alsocolumnAlignment().

void QGraphicsGridLayout::setColumnFixedWidth(int column,qreal width)

Sets the fixed width ofcolumn towidth.

void QGraphicsGridLayout::setColumnMaximumWidth(int column,qreal width)

Sets the maximum width ofcolumn towidth.

See alsocolumnMaximumWidth().

void QGraphicsGridLayout::setColumnMinimumWidth(int column,qreal width)

Sets the minimum width forcolumn towidth.

See alsocolumnMinimumWidth().

void QGraphicsGridLayout::setColumnPreferredWidth(int column,qreal width)

Sets the preferred width forcolumn towidth.

See alsocolumnPreferredWidth().

void QGraphicsGridLayout::setColumnSpacing(int column,qreal spacing)

Sets the spacing forcolumn tospacing.

See alsocolumnSpacing().

void QGraphicsGridLayout::setColumnStretchFactor(int column,int stretch)

Sets the stretch factor forcolumn tostretch.

See alsocolumnStretchFactor().

[virtual]void QGraphicsGridLayout::setGeometry(constQRectF & rect)

Reimplemented fromQGraphicsLayoutItem::setGeometry().

Sets the bounding geometry of the grid layout torect.

void QGraphicsGridLayout::setHorizontalSpacing(qreal spacing)

Sets the default horizontal spacing for the grid layout tospacing.

See alsohorizontalSpacing().

void QGraphicsGridLayout::setRowAlignment(int row,Qt::Alignment alignment)

Sets the alignment ofrow toalignment.

See alsorowAlignment().

void QGraphicsGridLayout::setRowFixedHeight(int row,qreal height)

Sets the fixed height for row,row, toheight.

void QGraphicsGridLayout::setRowMaximumHeight(int row,qreal height)

Sets the maximum height for row,row, toheight.

See alsorowMaximumHeight().

void QGraphicsGridLayout::setRowMinimumHeight(int row,qreal height)

Sets the minimum height for row,row, toheight.

See alsorowMinimumHeight().

void QGraphicsGridLayout::setRowPreferredHeight(int row,qreal height)

Sets the preferred height for row,row, toheight.

See alsorowPreferredHeight().

void QGraphicsGridLayout::setRowSpacing(int row,qreal spacing)

Sets the spacing forrow tospacing.

See alsorowSpacing().

void QGraphicsGridLayout::setRowStretchFactor(int row,int stretch)

Sets the stretch factor forrow tostretch.

See alsorowStretchFactor().

void QGraphicsGridLayout::setSpacing(qreal spacing)

Sets the grid layout's default spacing, both vertical and horizontal, tospacing.

See alsorowSpacing() andcolumnSpacing().

void QGraphicsGridLayout::setVerticalSpacing(qreal spacing)

Sets the default vertical spacing for the grid layout tospacing.

See alsoverticalSpacing().

[virtual]QSizeF QGraphicsGridLayout::sizeHint(Qt::SizeHint which, constQSizeF & constraint = QSizeF()) const

Reimplemented fromQGraphicsLayoutItem::sizeHint().

qreal QGraphicsGridLayout::verticalSpacing() const

Returns the default vertical spacing for the grid layout.

See alsosetVerticalSpacing().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp