QTableWidgetItemclass provides an item for use with theQTableWidget类。 更多 …
def
background
()
def
backgroundColor
()
def
checkState
()
def
column
()
def
flags
()
def
font
()
def
foreground
()
def
icon
()
def
isSelected
()
def
row
()
def
setBackground
(brush)
def
setBackgroundColor
(color)
def
setCheckState
(state)
def
setFlags
(flags)
def
setFont
(font)
def
setForeground
(brush)
def
setIcon
(icon)
def
setSelected
(select)
def
setSizeHint
(size)
def
setStatusTip
(statusTip)
def
setText
(text)
def
setTextAlignment
(alignment)
def
setTextColor
(color)
def
setToolTip
(toolTip)
def
setWhatsThis
(whatsThis)
def
sizeHint
()
def
statusTip
()
def
tableWidget
()
def
text
()
def
textAlignment
()
def
textColor
()
def
toolTip
()
def
type
()
def
whatsThis
()
Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes
QTableWidgetItemclass is a convenience class that replaces theQTableItemclass in Qt 3. It provides an item for use with theQTableWidget类。Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers:
QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg( pow(row, column+1))); tableWidget->setItem(row, column, newItem);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()with the appropriate value (seeItemFlags)。可复选项可以被复选和取消复选采用setCheckState()function. The correspondingcheckState()function indicates whether the item is currently checked.
当子类化
QTableWidgetItemto provide custom items, it is possible to define new types for them so that they can be distinguished from standard items. The constructors for subclasses that require this feature need to call the base class constructor with a new type value equal to or greater thanUserType.
QTableWidgetItem
(
icon
,
text
[
,
type=Type
]
)
¶
QTableWidgetItem(text[, type=Type])
QTableWidgetItem(other)
QTableWidgetItem([type=Type])
- param type
int- param icon
QIcon- param other
- param text
unicode
Constructs a table item with the given
icon
and
text
.
另请参阅
Constructs a table item with the given
text
.
另请参阅
Constructs a table item of the specified
type
that does not belong to any table.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
ItemType
¶
This enum describes the types that are used to describe table widget items.
|
常量 |
描述 |
|---|---|
|
QTableWidgetItem.Type |
The default type for table widget items. |
|
QTableWidgetItem.UserType |
The minimum value for custom types. Values below are reserved by Qt. |
可以定义新用户类型在
QTableWidgetItem
subclasses to ensure that custom items are treated specially.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
background
(
)
¶
QBrush
Returns the brush used to render the item’s background.
PySide2.QtWidgets.QTableWidgetItem.
backgroundColor
(
)
¶
QColor
注意
此函数被弃用。
This function is deprecated. Use
background()
代替。
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
checkState
(
)
¶
CheckState
Returns the checked state of the table item.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
clone
(
)
¶
Creates a copy of the item.
PySide2.QtWidgets.QTableWidgetItem.
column
(
)
¶
int
Returns the column of the item in the table. If the item is not in a table, this function will return -1.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
data
(
role
)
¶
role
–
int
object
Returns the item’s data for the given
role
.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
flags
(
)
¶
ItemFlags
返回用于描述项的标志。这些确定项是否可以被复选、编辑及选择。
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
font
(
)
¶
QFont
Returns the font used to render the item’s text.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
foreground
(
)
¶
QBrush
Returns the brush used to render the item’s foreground (e.g. text).
PySide2.QtWidgets.QTableWidgetItem.
icon
(
)
¶
QIcon
Returns the item’s icon.
PySide2.QtWidgets.QTableWidgetItem.
isSelected
(
)
¶
bool
返回
true
若项被选中,否则返回
false
.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
__lt__
(
other
)
¶
other
–
QTableWidgetItem
bool
PySide2.QtWidgets.QTableWidgetItem.
row
(
)
¶
int
Returns the row of the item in the table. If the item is not in a table, this function will return -1.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setBackground
(
brush
)
¶
brush
–
QBrush
Sets the item’s background brush to the specified
brush
。设置默认构造的笔刷将使视图使用来自样式的默认颜色。
PySide2.QtWidgets.QTableWidgetItem.
setBackgroundColor
(
color
)
¶
color
–
QColor
注意
此函数被弃用。
This function is deprecated. Use
setBackground()
代替。
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setCheckState
(
state
)
¶
state
–
CheckState
Sets the check state of the table item to be
state
.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setData
(
role
,
value
)
¶
role
–
int
value – object
Sets the item’s data for the given
role
到指定
value
.
注意
默认实现视
EditRole
and
DisplayRole
为引用相同数据。
另请参阅
ItemDataRole
data()
PySide2.QtWidgets.QTableWidgetItem.
setFlags
(
flags
)
¶
flags
–
ItemFlags
将项的标志设为给定
flags
. These determine whether the item can be selected or modified.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setFont
(
font
)
¶
font
–
QFont
Sets the font used to display the item’s text to the given
font
.
PySide2.QtWidgets.QTableWidgetItem.
setForeground
(
brush
)
¶
brush
–
QBrush
Sets the item’s foreground brush to the specified
brush
。设置默认构造的笔刷将使视图使用来自样式的默认颜色。
PySide2.QtWidgets.QTableWidgetItem.
setIcon
(
icon
)
¶
icon
–
QIcon
Sets the item’s icon to the
icon
指定。
PySide2.QtWidgets.QTableWidgetItem.
setSelected
(
select
)
¶
select
–
bool
将项的选定状态设为
select
.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setSizeHint
(
size
)
¶
size
–
QSize
Sets the size hint for the table item to be
size
。若没有设置尺寸提示或
size
无效,项委托将基于项数据计算尺寸提示。
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setStatusTip
(
statusTip
)
¶
statusTip – unicode
Sets the status tip for the table item to the text specified by
statusTip
.
QTableWidget
鼠标跟踪需要被启用此特征才工作。
PySide2.QtWidgets.QTableWidgetItem.
setText
(
text
)
¶
text – unicode
Sets the item’s text to the
text
指定。
PySide2.QtWidgets.QTableWidgetItem.
setTextAlignment
(
alignment
)
¶
alignment
–
int
Sets the text alignment for the item’s text to the
alignment
指定。
另请参阅
textAlignment()
Alignment
PySide2.QtWidgets.QTableWidgetItem.
setTextColor
(
color
)
¶
color
–
QColor
注意
此函数被弃用。
This function is deprecated. Use
setForeground()
代替。
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
setToolTip
(
toolTip
)
¶
toolTip – unicode
Sets the item’s tooltip to the string specified by
toolTip
.
PySide2.QtWidgets.QTableWidgetItem.
setWhatsThis
(
whatsThis
)
¶
whatsThis – unicode
Sets the item’s “What’s This?” help to the string specified by
whatsThis
.
PySide2.QtWidgets.QTableWidgetItem.
sizeHint
(
)
¶
QSize
Returns the size hint set for the table item.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
statusTip
(
)
¶
unicode
Returns the item’s status tip.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
tableWidget
(
)
¶
Returns the table widget that contains the item.
PySide2.QtWidgets.QTableWidgetItem.
textAlignment
(
)
¶
int
Returns the text alignment for the item’s text.
另请参阅
setTextAlignment()
Alignment
PySide2.QtWidgets.QTableWidgetItem.
textColor
(
)
¶
QColor
注意
此函数被弃用。
This function is deprecated. Use
foreground()
代替。
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
toolTip
(
)
¶
unicode
Returns the item’s tooltip.
另请参阅
PySide2.QtWidgets.QTableWidgetItem.
type
(
)
¶
int
返回类型被传递给
QTableWidgetItem
构造函数。
PySide2.QtWidgets.QTableWidgetItem.
whatsThis
(
)
¶
unicode
Returns the item’s “What’s This?” help.
另请参阅