Issue
I have a QObject based python class as follows:
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
class Validator(QObject):
authFailed = pyqtSignal(str, arguments=['value'])
def __init__(self, parent=None):
super(Validator, self).__init__(parent)
@pyqtslot
def test(self):
self.authFailed.emit("Failed")
On the qml side, I can listen to this signal as:
Validator {
onAuthFailed: {
}
id: validator
}
However, I am not sure how I can capture the str
parameter that is also emitted from the signal (The Failed
message). When I try something like: onAuthFailed(msg)
signature, this fails to compile.
Solution
I don't know about PyQt...
Usually, in QML you can access the signal parameters just by using their name.
According to this: http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#PyQt5.QtCore.pyqtSignal
the String you pass in the arguments=['value']
-list is the name, that is used to expose the parameter to QML.
So I am pretty sure, you can just use a variable value
in the handler in QML.
Try:
onAuthFailed: console.log('auth Failed: ', value)
Answered By - derM - not here for BOT dreams
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.