PySide2 Signal with named parameter

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


PySide2 Signal with named parameter



I am trying to replicate below example using PySide2.



https://evileg.com/en/post/242/



But as PySide2 doesn't support emitting a Signal with named parameter to QML, i have no clue about how to do this using PySide2 ?



Here is my code



main.py


from PySide2.QtGui import QGuiApplication
from PySide2.QtQml import QQmlApplicationEngine
from PySide2.QtCore import QObject, Signal, Slot, Property


class Calculator(QObject):
def __init__(self):
QObject.__init__(self)

sumResult = Signal(int)
subResult = Signal(int)

@Slot(int, int)
def sum(self, arg1, arg2):
self.sumResult.emit(arg1 + arg2)

@Slot(int, int)
def sub(self, arg1, arg2):
self.subResult.emit(arg1 - arg2)


if __name__ == "__main__":
import sys

app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
calculator = Calculator()
engine.rootContext().setContextProperty("calculator", calculator)
engine.load("/code/QML/calc.qml")

engine.quit.connect(app.quit)
sys.exit(app.exec_())









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived