table.dataChanged(index, index).connect(someFunction) 失败
table.dataChanged(index, index).connect(someFunction) fails
table = QTableView()
model = QStandardItemModel()
table.setModel(model)
r = table.model().rowCount()
c = table.model().columnCount()
tLeft = table.model().index(0, 0)
bRight = table.model().index(r, c)
table.dataChanged(tLeft, bRight).connect(SomeFunction)
AttributeError: 'NoneType' object has no attribute 'connect'
目标 - 当用户在 QTableView()
中直接更改其中一项时调用 SomeFunction
。
我做错了什么?我看到 NoneType 对象不能有属性 connect,但为什么它是 NoneType。
请评论。我是初学者。 Qt5.
你应该这样做:
table.model().dataChanged.connect(someFunction)
# or model.dataChanged.connect(someFunction)
不需要精确的论据。插槽应如下所示:
def someFunction(tLeft,bRight):
#do stuff
table = QTableView()
model = QStandardItemModel()
table.setModel(model)
r = table.model().rowCount()
c = table.model().columnCount()
tLeft = table.model().index(0, 0)
bRight = table.model().index(r, c)
table.dataChanged(tLeft, bRight).connect(SomeFunction)
AttributeError: 'NoneType' object has no attribute 'connect'
目标 - 当用户在 QTableView()
中直接更改其中一项时调用 SomeFunction
。
我做错了什么?我看到 NoneType 对象不能有属性 connect,但为什么它是 NoneType。
请评论。我是初学者。 Qt5.
你应该这样做:
table.model().dataChanged.connect(someFunction)
# or model.dataChanged.connect(someFunction)
不需要精确的论据。插槽应如下所示:
def someFunction(tLeft,bRight):
#do stuff