我需要向 QTreeWidgetItem 添加彩色动画,但在我的代码中,它会引发一些错误,有人可以帮助我吗?
代码示例在这里:
class TreeWigetItem(QTreeWidgetItem):
def __init__(self, parent=None):
super().__init__(parent)
@pyqtProperty(QBrush)
def bcolor(self):
return self.background(0)
@bcolor.setter
def bcolor(self, color):
self.setBackground(0, color)
self.setBackground(1, color)
并像这样调用方法:
child_item = TreeWigetItem()
self.child_item_ani = QPropertyAnimation(child_item, b'bcolor')
self.child_item_ani.setDuration(1000)
self.child_item_ani.setEndValue(QBrush(Qt.red))
self.child_item_ani.start()
这里的错误:
self.child_item_ani = QPropertyAnimation(child_item, b'bcolor')
TypeError: arguments did not match any overloaded call:
QPropertyAnimation(parent: QObject = None): argument 1 has unexpected type 'TreeWigetItem'
QPropertyAnimation(QObject, Union[QByteArray, bytes, bytearray], parent: QObject = None): argument 1 has unexpected type 'TreeWigetItem'
POPMUISE
跃然一笑
随时随地看视频慕课网APP
相关分类