QGraphicsGridLayout类提供在图形视图管理 Widget 的栅格。 更多 …
def
addItem
(item, row, column, rowSpan, columnSpan[, alignment=Qt.Alignment()])
def
addItem
(item, row, column[, alignment=Qt.Alignment()])
def
alignment
(item)
def
columnAlignment
(column)
def
columnCount
()
def
columnMaximumWidth
(column)
def
columnMinimumWidth
(column)
def
columnPreferredWidth
(column)
def
columnSpacing
(column)
def
columnStretchFactor
(column)
def
horizontalSpacing
()
def
itemAt
(row, column)
def
removeItem
(item)
def
rowAlignment
(row)
def
rowCount
()
def
rowMaximumHeight
(row)
def
rowMinimumHeight
(row)
def
rowPreferredHeight
(row)
def
rowSpacing
(row)
def
rowStretchFactor
(row)
def
setAlignment
(item, alignment)
def
setColumnAlignment
(column, alignment)
def
setColumnFixedWidth
(column, width)
def
setColumnMaximumWidth
(column, width)
def
setColumnMinimumWidth
(column, width)
def
setColumnPreferredWidth
(column, width)
def
setColumnSpacing
(column, spacing)
def
setColumnStretchFactor
(column, stretch)
def
setHorizontalSpacing
(spacing)
def
setRowAlignment
(row, alignment)
def
setRowFixedHeight
(row, height)
def
setRowMaximumHeight
(row, height)
def
setRowMinimumHeight
(row, height)
def
setRowPreferredHeight
(row, height)
def
setRowSpacing
(row, spacing)
def
setRowStretchFactor
(row, stretch)
def
setSpacing
(spacing)
def
setVerticalSpacing
(spacing)
def
verticalSpacing
()
The most common way to use
QGraphicsGridLayoutis 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 callingsetLayout().QGraphicsGridLayoutautomatically computes the dimensions of the grid as you add items.scene = QGraphicsScene() textEdit = scene.addWidget(QTextEdit()) pushButton = scene.addWidget(QPushButton()) layout = QGraphicsGridLayout() layout.addItem(textEdit, 0, 0) layout.addItem(pushButton, 0, 1) form = 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 ofsetOwnedByLayout()how to handle this. You can access each item in the layout by callingcount()anditemAt()。调用removeAt()will remove an item from the layout, without destroying it.
QGraphicsGridLayoutrespects 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.
QGraphicsGridLayout
(
[
parent=None
]
)
¶
- param parent
构造
QGraphicsGridLayout
实例。
parent
会被传递给
QGraphicsLayout
‘s constructor.
PySide2.QtWidgets.QGraphicsGridLayout.
addItem
(
item
,
row
,
column
[
,
alignment=Qt.Alignment()
]
)
¶
item
–
QGraphicsLayoutItem
row
–
int
column
–
int
alignment
–
Alignment
添加
item
to the grid on
row
and
column
. You can specify an optional
alignment
for
item
.
PySide2.QtWidgets.QGraphicsGridLayout.
addItem
(
item
,
row
,
column
,
rowSpan
,
columnSpan
[
,
alignment=Qt.Alignment()
]
)
¶
item
–
QGraphicsLayoutItem
row
–
int
column
–
int
rowSpan
–
int
columnSpan
–
int
alignment
–
Alignment
添加
item
to the grid on
row
and
column
. You can specify a
rowSpan
and
columnSpan
and an optional
alignment
.
PySide2.QtWidgets.QGraphicsGridLayout.
alignment
(
item
)
¶
item
–
QGraphicsLayoutItem
Alignment
返回对齐方式为
item
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
columnAlignment
(
column
)
¶
column
–
int
Alignment
返回对齐方式为
column
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
columnCount
(
)
¶
int
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).
PySide2.QtWidgets.QGraphicsGridLayout.
columnMaximumWidth
(
column
)
¶
column
–
int
qreal
返回最大宽度为
column
.
PySide2.QtWidgets.QGraphicsGridLayout.
columnMinimumWidth
(
column
)
¶
column
–
int
qreal
Returns the minimum width for
column
.
PySide2.QtWidgets.QGraphicsGridLayout.
columnPreferredWidth
(
column
)
¶
column
–
int
qreal
Returns the preferred width for
column
.
PySide2.QtWidgets.QGraphicsGridLayout.
columnSpacing
(
column
)
¶
column
–
int
qreal
Returns the column spacing for
column
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
columnStretchFactor
(
column
)
¶
column
–
int
int
Returns the stretch factor for
column
.
PySide2.QtWidgets.QGraphicsGridLayout.
horizontalSpacing
(
)
¶
qreal
Returns the default horizontal spacing for the grid layout.
PySide2.QtWidgets.QGraphicsGridLayout.
itemAt
(
row
,
column
)
¶
row
–
int
column
–
int
Returns a pointer to the layout item at (
row
,
column
).
PySide2.QtWidgets.QGraphicsGridLayout.
removeItem
(
item
)
¶
item
–
QGraphicsLayoutItem
移除布局项
item
without destroying it. Ownership of the item is transferred to the caller.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
rowAlignment
(
row
)
¶
row
–
int
Alignment
Returns the alignment of
row
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
rowCount
(
)
¶
int
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).
PySide2.QtWidgets.QGraphicsGridLayout.
rowMaximumHeight
(
row
)
¶
row
–
int
qreal
Returns the maximum height for row,
row
.
PySide2.QtWidgets.QGraphicsGridLayout.
rowMinimumHeight
(
row
)
¶
row
–
int
qreal
Returns the minimum height for row,
row
.
PySide2.QtWidgets.QGraphicsGridLayout.
rowPreferredHeight
(
row
)
¶
row
–
int
qreal
Returns the preferred height for row,
row
.
PySide2.QtWidgets.QGraphicsGridLayout.
rowSpacing
(
row
)
¶
row
–
int
qreal
Returns the row spacing for
row
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
rowStretchFactor
(
row
)
¶
row
–
int
int
Returns the stretch factor for
row
.
PySide2.QtWidgets.QGraphicsGridLayout.
setAlignment
(
item
,
alignment
)
¶
item
–
QGraphicsLayoutItem
alignment
–
Alignment
Sets the alignment for
item
to
alignment
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnAlignment
(
column
,
alignment
)
¶
column
–
int
alignment
–
Alignment
Sets the alignment for
column
to
alignment
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnFixedWidth
(
column
,
width
)
¶
column
–
int
width
–
qreal
Sets the fixed width of
column
to
width
.
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnMaximumWidth
(
column
,
width
)
¶
column
–
int
width
–
qreal
Sets the maximum width of
column
to
width
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnMinimumWidth
(
column
,
width
)
¶
column
–
int
width
–
qreal
Sets the minimum width for
column
to
width
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnPreferredWidth
(
column
,
width
)
¶
column
–
int
width
–
qreal
Sets the preferred width for
column
to
width
.
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnSpacing
(
column
,
spacing
)
¶
column
–
int
spacing
–
qreal
Sets the spacing for
column
to
spacing
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setColumnStretchFactor
(
column
,
stretch
)
¶
column
–
int
stretch
–
int
设置拉伸因子为
column
to
stretch
.
PySide2.QtWidgets.QGraphicsGridLayout.
setHorizontalSpacing
(
spacing
)
¶
spacing
–
qreal
Sets the default horizontal spacing for the grid layout to
spacing
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setRowAlignment
(
row
,
alignment
)
¶
row
–
int
alignment
–
Alignment
Sets the alignment of
row
to
alignment
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setRowFixedHeight
(
row
,
height
)
¶
row
–
int
height
–
qreal
Sets the fixed height for row,
row
,到
height
.
PySide2.QtWidgets.QGraphicsGridLayout.
setRowMaximumHeight
(
row
,
height
)
¶
row
–
int
height
–
qreal
Sets the maximum height for row,
row
,到
height
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setRowMinimumHeight
(
row
,
height
)
¶
row
–
int
height
–
qreal
Sets the minimum height for row,
row
,到
height
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setRowPreferredHeight
(
row
,
height
)
¶
row
–
int
height
–
qreal
Sets the preferred height for row,
row
,到
height
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setRowSpacing
(
row
,
spacing
)
¶
row
–
int
spacing
–
qreal
Sets the spacing for
row
to
spacing
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setRowStretchFactor
(
row
,
stretch
)
¶
row
–
int
stretch
–
int
设置拉伸因子为
row
to
stretch
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
setSpacing
(
spacing
)
¶
spacing
–
qreal
Sets the grid layout’s default spacing, both vertical and horizontal, to
spacing
.
PySide2.QtWidgets.QGraphicsGridLayout.
setVerticalSpacing
(
spacing
)
¶
spacing
–
qreal
Sets the default vertical spacing for the grid layout to
spacing
.
另请参阅
PySide2.QtWidgets.QGraphicsGridLayout.
verticalSpacing
(
)
¶
qreal
Returns the default vertical spacing for the grid layout.
另请参阅