QStandardItemclass provides an item for use with theQStandardItemModel类。 更多 …
def
accessibleDescription
()
def
accessibleText
()
def
appendColumn
(items)
def
appendRow
(item)
def
appendRow
(items)
def
appendRows
(items)
def
background
()
def
checkState
()
def
child
(row[, column=0])
def
clearData
()
def
column
()
def
columnCount
()
def
emitDataChanged
()
def
flags
()
def
font
()
def
foreground
()
def
hasChildren
()
def
icon
()
def
index
()
def
insertColumn
(column, items)
def
insertColumns
(column, count)
def
insertRow
(row, item)
def
insertRow
(row, items)
def
insertRows
(row, count)
def
insertRows
(row, items)
def
isAutoTristate
()
def
isCheckable
()
def
isDragEnabled
()
def
isDropEnabled
()
def
isEditable
()
def
isEnabled
()
def
isSelectable
()
def
isTristate
()
def
isUserTristate
()
def
model
()
def
parent
()
def
removeColumn
(column)
def
removeColumns
(column, count)
def
removeRow
(row)
def
removeRows
(row, count)
def
row
()
def
rowCount
()
def
setAccessibleDescription
(accessibleDescription)
def
setAccessibleText
(accessibleText)
def
setAutoTristate
(tristate)
def
setBackground
(brush)
def
setCheckState
(checkState)
def
setCheckable
(checkable)
def
setChild
(row, column, item)
def
setChild
(row, item)
def
setColumnCount
(columns)
def
setDragEnabled
(dragEnabled)
def
setDropEnabled
(dropEnabled)
def
setEditable
(editable)
def
setEnabled
(enabled)
def
setFlags
(flags)
def
setFont
(font)
def
setForeground
(brush)
def
setIcon
(icon)
def
setRowCount
(rows)
def
setSelectable
(selectable)
def
setSizeHint
(sizeHint)
def
setStatusTip
(statusTip)
def
setText
(text)
def
setTextAlignment
(textAlignment)
def
setToolTip
(toolTip)
def
setTristate
(tristate)
def
setUserTristate
(tristate)
def
setWhatsThis
(whatsThis)
def
sizeHint
()
def
sortChildren
(column[, order=Qt.AscendingOrder])
def
statusTip
()
def
takeChild
(row[, column=0])
def
takeColumn
(column)
def
takeRow
(row)
def
text
()
def
textAlignment
()
def
toolTip
()
def
whatsThis
()
Items usually contain text, icons, or checkboxes.
Each item can have its own background brush which is set with the
setBackground()function. The current background brush can be found withbackground(). The text label for each item can be rendered with its own font and brush. These are specified with thesetFont()andsetForeground()functions, and read withfont()andforeground().By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. Each item’s flags can be changed by calling
setFlags(). Checkable items can be checked and unchecked with thesetCheckState()function. The correspondingcheckState()function indicates whether the item is currently checked.You can store application-specific data in an item by calling
setData().Each item can have a two-dimensional table of child items. This makes it possible to build hierarchies of items. The typical hierarchy is the tree, in which case the child table is a table with a single column (a list).
The dimensions of the child table can be set with
setRowCount()andsetColumnCount(). Items can be positioned in the child table withsetChild(). Get a pointer to a child item withchild(). New rows and columns of children can also be inserted withinsertRow()andinsertColumn(), or appended withappendRow()andappendColumn(). When using the append and insert functions, the dimensions of the child table will grow as needed.An existing row of children can be removed with
removeRow()ortakeRow(); correspondingly, a column can be removed withremoveColumn()ortakeColumn().An item’s children can be sorted by calling
sortChildren().
当子类化
QStandardItemto provide custom items, it is possible to define new types for them so that they can be distinguished from the base class. Thetype()function should be reimplemented to return a new type value equal to or greater thanUserType.Reimplement
data()andsetData()if you want to perform custom handling of data queries and/or control how an item’s data is represented.Reimplement
clone()if you wantQStandardItemModelto be able to create instances of your custom item class on demand (seesetItemPrototype()).Reimplement
read()andwrite()if you want to control how items are represented in their serialized form.Reimplement
operatorif you want to control the semantics of item comparison.operatordetermines the sorted order when sorting items withsortChildren()or withsort().
QStandardItem
¶
QStandardItem(icon, text)
QStandardItem(other)
QStandardItem(text)
QStandardItem(rows[, columns=1])
- param columns
int- param rows
int- param icon
- param other
- param text
unicode
Constructs an item.
Constructs an item with
rows
rows and
columns
columns of child items.
PySide2.QtGui.QStandardItem.
ItemType
¶
This enum describes the types that are used to describe standard items.
|
常量 |
描述 |
|---|---|
|
QStandardItem.Type |
The default type for standard items. |
|
QStandardItem.UserType |
The minimum value for custom types. Values below are reserved by Qt. |
可以定义新用户类型在
QStandardItem
子类以确保自定义项得到特殊处理;例如,当排序项时。
另请参阅
PySide2.QtGui.QStandardItem.
accessibleDescription
(
)
¶
unicode
Returns the item’s accessible description.
The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).
PySide2.QtGui.QStandardItem.
accessibleText
(
)
¶
unicode
Returns the item’s accessible text.
The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).
PySide2.QtGui.QStandardItem.
appendColumn
(
items
)
¶
items –
Appends a column containing
items
. If necessary, the row count is increased to the size of
items
.
另请参阅
PySide2.QtGui.QStandardItem.
appendRow
(
item
)
¶
item
–
QStandardItem
这是重载函数。
Appends a row containing
item
.
When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.
PySide2.QtGui.QStandardItem.
appendRow
(
items
)
¶
items –
PySide2.QtGui.QStandardItem.
appendRows
(
items
)
¶
items –
Appends rows containing
items
. The column count will not change.
另请参阅
PySide2.QtGui.QStandardItem.
background
(
)
¶
Returns the brush used to render the item’s background.
PySide2.QtGui.QStandardItem.
checkState
(
)
¶
CheckState
Returns the checked state of the item.
PySide2.QtGui.QStandardItem.
child
(
row
[
,
column=0
]
)
¶
row
–
int
column
–
int
Returns the child item at (
row
,
column
) if one has been set; otherwise returns
None
.
PySide2.QtGui.QStandardItem.
clearData
(
)
¶
Removes all the data from all roles previously set.
PySide2.QtGui.QStandardItem.
clone
(
)
¶
Returns a copy of this item. The item’s children are not copied.
当子类化
QStandardItem
, you can reimplement this function to provide
QStandardItemModel
with a factory that it can use to create new items on demand.
另请参阅
setItemPrototype()
operator=()
PySide2.QtGui.QStandardItem.
column
(
)
¶
int
Returns the column where the item is located in its parent’s child table, or -1 if the item has no parent.
PySide2.QtGui.QStandardItem.
columnCount
(
)
¶
int
Returns the number of child item columns that the item has.
PySide2.QtGui.QStandardItem.
data
(
[
role=Qt.UserRole + 1
]
)
¶
role
–
int
object
Returns the item’s data for the given
role
, or an invalid
QVariant
if there is no data for the role.
注意
默认实现视
EditRole
and
DisplayRole
为引用相同数据。
另请参阅
PySide2.QtGui.QStandardItem.
emitDataChanged
(
)
¶
促使关联此项的模型发射
dataChanged
() 信号对于此项。
通常只需调用此函数若有子类化
QStandardItem
和重实现
data()
and/or
setData()
.
另请参阅
PySide2.QtGui.QStandardItem.
flags
(
)
¶
ItemFlags
Returns the item flags for the item.
The item flags determine how the user can interact with the item.
By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target.
另请参阅
PySide2.QtGui.QStandardItem.
font
(
)
¶
Returns the font used to render the item’s text.
另请参阅
PySide2.QtGui.QStandardItem.
foreground
(
)
¶
Returns the brush used to render the item’s foreground (e.g. text).
PySide2.QtGui.QStandardItem.
hasChildren
(
)
¶
bool
返回
true
if this item has any children; otherwise returns
false
.
PySide2.QtGui.QStandardItem.
index
(
)
¶
QModelIndex
返回
QModelIndex
associated with this item.
When you need to invoke item functionality in a
QModelIndex
-based API (e.g.
QAbstractItemView
), you can call this function to obtain an index that corresponds to the item’s location in the model.
If the item is not associated with a model, an invalid
QModelIndex
被返回。
另请参阅
PySide2.QtGui.QStandardItem.
insertColumn
(
column
,
items
)
¶
column
–
int
items –
Inserts a column at
column
containing
items
. If necessary, the row count is increased to the size of
items
.
PySide2.QtGui.QStandardItem.
insertColumns
(
column
,
count
)
¶
column
–
int
count
–
int
插入
count
columns of child items at column
column
.
PySide2.QtGui.QStandardItem.
insertRow
(
row
,
item
)
¶
row
–
int
item
–
QStandardItem
这是重载函数。
Inserts a row at
row
containing
item
.
When building a list or a tree that has only one column, this function provides a convenient way to insert a single new item.
PySide2.QtGui.QStandardItem.
insertRow
(
row
,
items
)
¶
row
–
int
items –
PySide2.QtGui.QStandardItem.
insertRows
(
row
,
items
)
¶
row
–
int
items –
PySide2.QtGui.QStandardItem.
insertRows
(
row
,
count
)
¶
row
–
int
count
–
int
插入
count
rows of child items at row
row
.
PySide2.QtGui.QStandardItem.
isAutoTristate
(
)
¶
bool
Returns whether the item is tristate and is controlled by
QTreeWidget
.
默认值为 false。
PySide2.QtGui.QStandardItem.
isCheckable
(
)
¶
bool
Returns whether the item is user-checkable.
默认值为 false。
PySide2.QtGui.QStandardItem.
isDragEnabled
(
)
¶
bool
Returns whether the item is drag enabled. An item that is drag enabled can be dragged by the user.
默认值为 true。
Note that item dragging must be enabled in the view for dragging to work; see
dragEnabled
.
PySide2.QtGui.QStandardItem.
isDropEnabled
(
)
¶
bool
Returns whether the item is drop enabled. When an item is drop enabled, it can be used as a drop target.
默认值为 true。
PySide2.QtGui.QStandardItem.
isEditable
(
)
¶
bool
Returns whether the item can be edited by the user.
When an item is editable (and enabled), the user can edit the item by invoking one of the view’s edit triggers; see
editTriggers
.
默认值为 true。
另请参阅
PySide2.QtGui.QStandardItem.
isEnabled
(
)
¶
bool
Returns whether the item is enabled.
When an item is enabled, the user can interact with it. The possible types of interaction are specified by the other item flags, such as
isEditable()
and
isSelectable()
.
默认值为 true。
另请参阅
PySide2.QtGui.QStandardItem.
isSelectable
(
)
¶
bool
Returns whether the item is selectable by the user.
默认值为 true。
另请参阅
PySide2.QtGui.QStandardItem.
isTristate
(
)
¶
bool
注意
此函数被弃用。
使用
isAutoTristate()
instead. For a tristate checkbox that the user can change between all three states, use
isUserTristate()
代替。
PySide2.QtGui.QStandardItem.
isUserTristate
(
)
¶
bool
Returns whether the item is tristate; that is, if it’s checkable with three separate states and the user can cycle through all three states.
默认值为 false。
PySide2.QtGui.QStandardItem.
model
(
)
¶
返回
QStandardItemModel
that this item belongs to.
If the item is not a child of another item that belongs to the model, this function returns
None
.
另请参阅
PySide2.QtGui.QStandardItem.
parent
(
)
¶
Returns the item’s parent item, or
None
if the item has no parent.
注意
For toplevel items returns
None
. To receive toplevel item’s parent use
invisibleRootItem()
代替。
PySide2.QtGui.QStandardItem.
read
(
in
)
¶
in
–
QDataStream
读取项从流
in
. Only the data and flags of the item are read, not the child items.
另请参阅
PySide2.QtGui.QStandardItem.
removeColumn
(
column
)
¶
column
–
int
移除给定
column
. The items that were in the column are deleted.
PySide2.QtGui.QStandardItem.
removeColumns
(
column
,
count
)
¶
column
–
int
count
–
int
移除
count
columns at column
column
. The items that were in those columns are deleted.
PySide2.QtGui.QStandardItem.
removeRow
(
row
)
¶
row
–
int
移除给定
row
. The items that were in the row are deleted.
PySide2.QtGui.QStandardItem.
removeRows
(
row
,
count
)
¶
row
–
int
count
–
int
移除
count
rows at row
row
. The items that were in those rows are deleted.
PySide2.QtGui.QStandardItem.
row
(
)
¶
int
Returns the row where the item is located in its parent’s child table, or -1 if the item has no parent.
PySide2.QtGui.QStandardItem.
rowCount
(
)
¶
int
Returns the number of child item rows that the item has.
PySide2.QtGui.QStandardItem.
setAccessibleDescription
(
accessibleDescription
)
¶
accessibleDescription – unicode
Sets the item’s accessible description to the string specified by
accessibleDescription
.
The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).
PySide2.QtGui.QStandardItem.
setAccessibleText
(
accessibleText
)
¶
accessibleText – unicode
Sets the item’s accessible text to the string specified by
accessibleText
.
The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).
PySide2.QtGui.QStandardItem.
setAutoTristate
(
tristate
)
¶
tristate
–
bool
Determines that the item is tristate and controlled by
QTreeWidget
if
tristate
is
true
. This enables automatic management of the state of parent items in
QTreeWidget
(checked if all children are checked, unchecked if all children are unchecked, or partially checked if only some children are checked).
PySide2.QtGui.QStandardItem.
setBackground
(
brush
)
¶
brush
–
QBrush
Sets the item’s background brush to the specified
brush
.
PySide2.QtGui.QStandardItem.
setCheckState
(
checkState
)
¶
checkState
–
CheckState
Sets the check state of the item to be
state
.
PySide2.QtGui.QStandardItem.
setCheckable
(
checkable
)
¶
checkable
–
bool
Sets whether the item is user-checkable. If
checkable
is true, the item can be checked by the user; otherwise, the user cannot check the item.
The item delegate will render a checkable item with a check box next to the item’s text.
PySide2.QtGui.QStandardItem.
setChild
(
row
,
column
,
item
)
¶
row
–
int
column
–
int
item
–
QStandardItem
Sets the child item at (
row
,
column
) 到
item
. This item (the parent item) takes ownership of
item
. If necessary, the row count and column count are increased to fit the item.
注意
传递
None
as
item
removes the item.
另请参阅
PySide2.QtGui.QStandardItem.
setChild
(
row
,
item
)
¶
row
–
int
item
–
QStandardItem
这是重载函数。
Sets the child at
row
to
item
.
PySide2.QtGui.QStandardItem.
setColumnCount
(
columns
)
¶
columns
–
int
Sets the number of child item columns to
columns
. If this is less than
columnCount()
, the data in the unwanted columns is discarded.
PySide2.QtGui.QStandardItem.
setData
(
value
[
,
role=Qt.UserRole + 1
]
)
¶
value – object
role
–
int
Sets the item’s data for the given
role
到指定
value
.
If you subclass
QStandardItem
and reimplement this function, your reimplementation should call
emitDataChanged()
if you do not call the base implementation of . This will ensure that e.g. views using the model are notified of the changes.
注意
默认实现视
EditRole
and
DisplayRole
为引用相同数据。
另请参阅
ItemDataRole
data()
setFlags()
PySide2.QtGui.QStandardItem.
setDragEnabled
(
dragEnabled
)
¶
dragEnabled
–
bool
Sets whether the item is drag enabled. If
dragEnabled
is true, the item can be dragged by the user; otherwise, the user cannot drag the item.
Note that you also need to ensure that item dragging is enabled in the view; see
dragEnabled
.
PySide2.QtGui.QStandardItem.
setDropEnabled
(
dropEnabled
)
¶
dropEnabled
–
bool
Sets whether the item is drop enabled. If
dropEnabled
is true, the item can be used as a drop target; otherwise, it cannot.
Note that you also need to ensure that drops are enabled in the view; see
acceptDrops()
; and that the model supports the desired drop actions; see
supportedDropActions()
.
PySide2.QtGui.QStandardItem.
setEditable
(
editable
)
¶
editable
–
bool
Sets whether the item is editable. If
editable
is true, the item can be edited by the user; otherwise, the user cannot edit the item.
How the user can edit items in a view is determined by the view’s edit triggers; see
editTriggers
.
另请参阅
PySide2.QtGui.QStandardItem.
setEnabled
(
enabled
)
¶
enabled
–
bool
Sets whether the item is enabled. If
enabled
is true, the item is enabled, meaning that the user can interact with the item; if
enabled
is false, the user cannot interact with the item.
This flag takes precedence over the other item flags; e.g. if an item is not enabled, it cannot be selected by the user, even if the
ItemIsSelectable
flag has been set.
另请参阅
isEnabled()
ItemIsEnabled
setFlags()
PySide2.QtGui.QStandardItem.
setFlags
(
flags
)
¶
flags
–
ItemFlags
Sets the item flags for the item to
flags
.
The item flags determine how the user can interact with the item. This is often used to disable an item.
PySide2.QtGui.QStandardItem.
setFont
(
font
)
¶
font
–
QFont
Sets the font used to display the item’s text to the given
font
.
PySide2.QtGui.QStandardItem.
setForeground
(
brush
)
¶
brush
–
QBrush
Sets the brush used to display the item’s foreground (e.g. text) to the given
brush
.
PySide2.QtGui.QStandardItem.
setIcon
(
icon
)
¶
icon
–
QIcon
Sets the item’s icon to the
icon
指定。
另请参阅
PySide2.QtGui.QStandardItem.
setRowCount
(
rows
)
¶
rows
–
int
Sets the number of child item rows to
rows
. If this is less than
rowCount()
, the data in the unwanted rows is discarded.
PySide2.QtGui.QStandardItem.
setSelectable
(
selectable
)
¶
selectable
–
bool
Sets whether the item is selectable. If
selectable
is true, the item can be selected by the user; otherwise, the user cannot select the item.
You can control the selection behavior and mode by manipulating their view properties; see
selectionMode
and
selectionBehavior
.
另请参阅
PySide2.QtGui.QStandardItem.
setSizeHint
(
sizeHint
)
¶
sizeHint
–
QSize
Sets the size hint for the item to be
size
. If no size hint is set, the item delegate will compute the size hint based on the item data.
另请参阅
PySide2.QtGui.QStandardItem.
setStatusTip
(
statusTip
)
¶
statusTip – unicode
Sets the item’s status tip to the string specified by
statusTip
.
PySide2.QtGui.QStandardItem.
setText
(
text
)
¶
text – unicode
Sets the item’s text to the
text
指定。
PySide2.QtGui.QStandardItem.
setTextAlignment
(
textAlignment
)
¶
textAlignment
–
Alignment
Sets the text alignment for the item’s text to the
alignment
指定。
另请参阅
PySide2.QtGui.QStandardItem.
setToolTip
(
toolTip
)
¶
toolTip – unicode
Sets the item’s tooltip to the string specified by
toolTip
.
PySide2.QtGui.QStandardItem.
setTristate
(
tristate
)
¶
tristate
–
bool
注意
此函数被弃用。
使用
setAutoTristate
(bool tristate) instead. For a tristate checkbox that the user can change between all three states, use
setUserTristate
(bool tristate) instead.
另请参阅
PySide2.QtGui.QStandardItem.
setUserTristate
(
tristate
)
¶
tristate
–
bool
Sets whether the item is tristate and controlled by the user. If
tristate
is true, the user can cycle through three separate states; otherwise, the item is checkable with two states. (Note that this also requires that the item is checkable; see
isCheckable()
.)
PySide2.QtGui.QStandardItem.
setWhatsThis
(
whatsThis
)
¶
whatsThis – unicode
Sets the item’s “What’s This?” help to the string specified by
whatsThis
.
PySide2.QtGui.QStandardItem.
sizeHint
(
)
¶
QSize
Returns the size hint set for the item, or an invalid
QSize
if no size hint has been set.
If no size hint has been set, the item delegate will compute the size hint based on the item data.
另请参阅
PySide2.QtGui.QStandardItem.
sortChildren
(
column
[
,
order=Qt.AscendingOrder
]
)
¶
column
–
int
order
–
SortOrder
排序项的子级使用给定
order
,通过值在给定
column
.
注意
This function is recursive, therefore it sorts the children of the item, its grandchildren, etc.
另请参阅
operator
PySide2.QtGui.QStandardItem.
statusTip
(
)
¶
unicode
Returns the item’s status tip.
PySide2.QtGui.QStandardItem.
takeChild
(
row
[
,
column=0
]
)
¶
row
–
int
column
–
int
Removes the child item at (
row
,
column
) without deleting it, and returns a pointer to the item. If there was no child at the given location, then this function returns
None
.
Note that this function, unlike
takeRow()
and
takeColumn()
, does not affect the dimensions of the child table.
另请参阅
PySide2.QtGui.QStandardItem.
takeColumn
(
column
)
¶
column
–
int
移除
column
without deleting the column items, and returns a list of pointers to the removed items. For items in the column that have not been set, the corresponding pointers in the list will be
None
.
PySide2.QtGui.QStandardItem.
takeRow
(
row
)
¶
row
–
int
移除
row
without deleting the row items, and returns a list of pointers to the removed items. For items in the row that have not been set, the corresponding pointers in the list will be
None
.
PySide2.QtGui.QStandardItem.
text
(
)
¶
unicode
Returns the item’s text. This is the text that’s presented to the user in a view.
另请参阅
PySide2.QtGui.QStandardItem.
textAlignment
(
)
¶
Alignment
Returns the text alignment for the item’s text.
另请参阅
PySide2.QtGui.QStandardItem.
toolTip
(
)
¶
unicode
Returns the item’s tooltip.
PySide2.QtGui.QStandardItem.
type
(
)
¶
int
Returns the type of this item. The type is used to distinguish custom items from the base class. When subclassing
QStandardItem
, you should reimplement this function and return a new value greater than or equal to
UserType
.
另请参阅
Type
PySide2.QtGui.QStandardItem.
whatsThis
(
)
¶
unicode
Returns the item’s “What’s This?” help.