QGraphicsGridLayout Class Reference

[ QtGui module]

The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View. 更多...

继承 QGraphicsLayout .

方法


详细描述

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.

 QGraphicsScene scene;
 QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
 QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);
 QGraphicsGridLayout *layout = new QGraphicsGridLayout;
 layout->addItem(textEdit, 0, 0);
 layout->addItem(pushButton, 0, 1);
 QGraphicsWidget *form = new QGraphicsWidget;
 form->setLayout(layout);
 scene.addItem(form);
			

The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (譬如 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 () 和 itemAt (). Calling removeAt () will remove an item from the layout, without destroying it.

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


方法文档编制

QGraphicsGridLayout.__init__ ( self , QGraphicsLayoutItem   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsGridLayout 实例。 parent 会被传递给 QGraphicsLayout 的构造函数。

QGraphicsGridLayout.addItem ( self , QGraphicsLayoutItem   item , int  row , int  column , int  rowSpan , int  columnSpan , Qt.Alignment   alignment  = 0)

item argument has it's ownership transferred to Qt.

添加 item to the grid on row and column . You can specify a rowSpan and columnSpan 和 optional alignment .

QGraphicsGridLayout.addItem ( self , QGraphicsLayoutItem   aitem , int  arow , int  acolumn , Qt.Alignment   alignment  = 0)

aitem argument, if not None, causes self to be owned by Qt instead of PyQt.

添加 item to the grid on row and column . You can specify an optional alignment for item .

Qt.Alignment QGraphicsGridLayout.alignment ( self , QGraphicsLayoutItem   item )

Returns the alignment for item .

另请参阅 setAlignment ().

Qt.Alignment QGraphicsGridLayout.columnAlignment ( self , int  column )

Returns the alignment for column .

另请参阅 setColumnAlignment ().

int QGraphicsGridLayout.columnCount ( self )

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

float QGraphicsGridLayout.columnMaximumWidth ( self , int  column )

Returns the maximum width for column .

另请参阅 setColumnMaximumWidth ().

float QGraphicsGridLayout.columnMinimumWidth ( self , int  column )

Returns the minimum width for column .

另请参阅 setColumnMinimumWidth ().

float QGraphicsGridLayout.columnPreferredWidth ( self , int  column )

Returns the preferred width for column .

另请参阅 setColumnPreferredWidth ().

float QGraphicsGridLayout.columnSpacing ( self , int  column )

Returns the column spacing for column .

另请参阅 setColumnSpacing ().

int QGraphicsGridLayout.columnStretchFactor ( self , int  column )

Returns the stretch factor for column .

另请参阅 setColumnStretchFactor ().

int QGraphicsGridLayout.count ( self )

重实现自 QGraphicsLayout.count ().

Returns the number of layout items in this grid layout.

float QGraphicsGridLayout.horizontalSpacing ( self )

Returns the default horizontal spacing for the grid layout.

另请参阅 setHorizontalSpacing ().

QGraphicsGridLayout.invalidate ( self )

重实现自 QGraphicsLayout.invalidate ().

QGraphicsLayoutItem QGraphicsGridLayout.itemAt ( self , int  row , int  column )

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

QGraphicsLayoutItem QGraphicsGridLayout.itemAt ( self , int  index )

重实现自 QGraphicsLayout.itemAt ().

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

QGraphicsGridLayout.removeAt ( self , int  index )

重实现自 QGraphicsLayout.removeAt ().

移除布局项在 index without destroying it. Ownership of the item is transferred to the caller.

另请参阅 addItem ().

QGraphicsGridLayout.removeItem ( self , QGraphicsLayoutItem   item )

item argument

移除布局项 item without destroying it. Ownership of the item is transferred to the caller.

该函数在 Qt 4.8 引入。

另请参阅 addItem ().

Qt.Alignment QGraphicsGridLayout.rowAlignment ( self , int  row )

Returns the alignment of row .

另请参阅 setRowAlignment ().

int QGraphicsGridLayout.rowCount ( self )

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

float QGraphicsGridLayout.rowMaximumHeight ( self , int  row )

Returns the maximum height for row, row .

另请参阅 setRowMaximumHeight ().

float QGraphicsGridLayout.rowMinimumHeight ( self , int  row )

Returns the minimum height for row, row .

另请参阅 setRowMinimumHeight ().

float QGraphicsGridLayout.rowPreferredHeight ( self , int  row )

Returns the preferred height for row, row .

另请参阅 setRowPreferredHeight ().

float QGraphicsGridLayout.rowSpacing ( self , int  row )

Returns the row spacing for row .

另请参阅 setRowSpacing ().

int QGraphicsGridLayout.rowStretchFactor ( self , int  row )

Returns the stretch factor for row .

另请参阅 setRowStretchFactor ().

QGraphicsGridLayout.setAlignment ( self , QGraphicsLayoutItem   item , Qt.Alignment   alignment )

Sets the alignment for item to alignment .

另请参阅 alignment ().

QGraphicsGridLayout.setColumnAlignment ( self , int  column , Qt.Alignment   alignment )

Sets the alignment for column to alignment .

另请参阅 columnAlignment ().

QGraphicsGridLayout.setColumnFixedWidth ( self , int  column , float  width )

Sets the fixed width of column to width .

QGraphicsGridLayout.setColumnMaximumWidth ( self , int  column , float  width )

Sets the maximum width of column to width .

另请参阅 columnMaximumWidth ().

QGraphicsGridLayout.setColumnMinimumWidth ( self , int  column , float  width )

Sets the minimum width for column to width .

另请参阅 columnMinimumWidth ().

QGraphicsGridLayout.setColumnPreferredWidth ( self , int  column , float  width )

Sets the preferred width for column to width .

另请参阅 columnPreferredWidth ().

QGraphicsGridLayout.setColumnSpacing ( self , int  column , float  spacing )

Sets the spacing for column to spacing .

另请参阅 columnSpacing ().

QGraphicsGridLayout.setColumnStretchFactor ( self , int  column , int  stretch )

设置拉伸因子为 column to stretch .

另请参阅 columnStretchFactor ().

QGraphicsGridLayout.setGeometry ( self , QRectF   rect )

重实现自 QGraphicsLayoutItem.setGeometry ().

Sets the bounding geometry of the grid layout to rect .

QGraphicsGridLayout.setHorizontalSpacing ( self , float  spacing )

Sets the default horizontal spacing for the grid layout to spacing .

另请参阅 horizontalSpacing ().

QGraphicsGridLayout.setRowAlignment ( self , int  row , Qt.Alignment   alignment )

Sets the alignment of row to alignment .

另请参阅 rowAlignment ().

QGraphicsGridLayout.setRowFixedHeight ( self , int  row , float  height )

Sets the fixed height for row, row , to height .

QGraphicsGridLayout.setRowMaximumHeight ( self , int  row , float  height )

Sets the maximum height for row, row , to height .

另请参阅 rowMaximumHeight ().

QGraphicsGridLayout.setRowMinimumHeight ( self , int  row , float  height )

Sets the minimum height for row, row , to height .

另请参阅 rowMinimumHeight ().

QGraphicsGridLayout.setRowPreferredHeight ( self , int  row , float  height )

Sets the preferred height for row, row , to height .

另请参阅 rowPreferredHeight ().

QGraphicsGridLayout.setRowSpacing ( self , int  row , float  spacing )

Sets the spacing for row to spacing .

另请参阅 rowSpacing ().

QGraphicsGridLayout.setRowStretchFactor ( self , int  row , int  stretch )

设置拉伸因子为 row to stretch .

另请参阅 rowStretchFactor ().

QGraphicsGridLayout.setSpacing ( self , float  spacing )

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

另请参阅 rowSpacing () 和 columnSpacing ().

QGraphicsGridLayout.setVerticalSpacing ( self , float  spacing )

Sets the default vertical spacing for the grid layout to spacing .

另请参阅 verticalSpacing ().

QSizeF QGraphicsGridLayout.sizeHint ( self , Qt.SizeHint   which , QSizeF   constraint  = QSizeF())

重实现自 QGraphicsLayoutItem.sizeHint ().

float QGraphicsGridLayout.verticalSpacing ( self )

Returns the default vertical spacing for the grid layout.

另请参阅 setVerticalSpacing ().