在 PyQt5 中,你会这样做:
from PyQt5.QtCore import pyqtSignal
sumResult = pyqtSignal(int, arguments=['sum'])
sumResult.emit(42)
然后在 QML 中:
onSumResult: console.log(sum)
仅使用 PySide2 信号不起作用:
from PySide2.QtCore import Signal
sumResult = Signal(int, arguments=['sum'])
sumResult.emit(42)
错误:
TypeError: 'arguments' is an invalid keyword argument for this function