I want to connect to C++ signals from QML like this:
action.onMouseUp = function() {
console.log("mouse up>>");
}
And declare in my C++ object this signal:
signals:
void mouseUp(const QPointF point);
But I'm getting QML Error: TypeError: Cannot assign to read-only property "mouseUp". What might the problem be?
You need to call connect method of action.onMouseUp object.
action.onMouseUp.connect( function() {
console.log("mouse up>>");
});
I found another solution:
Q_PROPERTY(QJSValue onMouseUp READ onMouseUp WRITE setOnMouseUp)
It works even without connect()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.