我正在尝试连接QFileSystemModel.dataChanged
信号,但到目前为止还没有运气。下面的代码产生了这个错误:
类型错误:字节或 ASCII 字符串不应为“列表”
import sys
from PyQt5 import QtGui, QtWidgets, QtCore
from PyQt5.QtWidgets import QFileSystemModel, QTreeView
from PyQt5.QtCore import QDir
class DirectoryTreeWidget(QTreeView):
def __init__(self, path=QDir.currentPath(), *args, **kwargs):
super(DirectoryTreeWidget, self).__init__(*args, **kwargs)
self.model = QFileSystemModel()
self.model.dataChanged[QtCore.QModelIndex,QtCore.QModelIndex,[]].connect(self.dataChanged)
def dataChanged(self, topLeft, bottomRight, roles):
print('dataChanged', topLeft, bottomRight, roles)
def main():
app = QtWidgets.QApplication(sys.argv)
ex = DirectoryTreeWidget()
ex.set_extensions(["*.txt"])
sys.exit(app.exec_())
if __name__ == "__main__":
main()
我如何在 PyQt5 中连接这个信号?