-
Notifications
You must be signed in to change notification settings - Fork 18
Params are not available in qml handlers #8
Comments
@vchekan thanks for the issue! Unfortunately, at the moment attributes' names are erased on signal registration, we will try to see if there is a way to preserve them. Currently, there are two possible workarounds:
Remember, that in JS you can always check what are the arguments of the function (see this answer on SO) Component.onCompleted: {
visible = true;
logic.pageDownloaded.connect(jsPageDownloaded);
}
function jsPageDownloaded(response) {
console.log("Page downloaded " + response);
}
// ... |
Edit2: Note, that the following is just an explanation of why named attributes are missing and should not be used, as it is soon to be fixed. You can also access attributes by using onPageDownloaded: console.log("Page downloaded " + arg0); Edit: note that this is the consequence of erasing attributes' names, not how JS in QML works. |
it might be better not to use |
@dathinab yes, preserving attributes' names is soon to be added, totally shouldn't have advised that, I'll fix my comment right away. And yes, there's still so much to reconsider about, especially about macros -- they are made to work on stable rust, but, in result are monstrous and inflexible. I've been thinking about using macros 1.1, but these are just 'custom derives', so making qtobjects out of rust's structures can turn tedious: #10. Edit: grammar fixes. |
This is not blocked anymore |
There is a demonstration of how rust object signal can be connected to qml object, but there is no demo of how parameter is passed even though signal is defined with one param
fn pageDownloaded(response: String)
.https://github.com/White-Oak/qml-rust/blob/master/examples/threaded.qml#L28
If I try to modify handler to
onPageDownloaded: console.log("Page Downloaded "+ response);
then I get error at runtime:threaded.qml:28: ReferenceError: response is not defined
The text was updated successfully, but these errors were encountered: