4 ms·
Not OP, but QML is not a great language to put more logic than simple bindings and functions like Button { text: "Save" enabled: textField.
by ognarb 3y ago
Not OP, but QML is not a great language to put more logic than simple bindings and functions like
Button {
text: "Save"
enabled: textField.text.length > 0 // this is reactive to the value of a TextField
onClicked: Backend.save()
}
as soon as you try to for example implement the save method in JS/QML this starts to become very painful as it often ends up with a lot of spaghetti code. The very cool thing with QML is that the save function can be simply implemented in C++ like this.
Backend::save()
{
// call QFile/QNetworkRequest/...
}
It force the programmer to split their logic from the UI layer which I don't consider a bad thing.
- JanisErdmanis 3y agoIt is also possible to have a backend implemented in JS in similar way. Though I personally only have used in intial UI prototype which I latter swapped with Julia backend.
- notyoutube 3y agoI'm curious about julia as a gui language: mind sharing your code/project?
- JanisErdmanis 3y agoI have developed/prototyped a voting client with QML/Julia in PeaceFounderClient [1]. Few weeks ago I made bundling setup for it and have published bundles [2]. This may not scale well but I opted for bridging the backend with frontend in top scope with Bridge.qml [3] which on the Julia side is loaded with ‘loadqml’ using ‘QML.jl’ pacakge [4]. [1]: https://github.com/PeaceFounder/PeaceFounderClient/tree/main https://github.com/PeaceFounder/PeaceFounderClient/tree/main [2]: https://github.com/PeaceFounder/PeaceFounderClient/releases https://github.com/PeaceFounder/PeaceFounderClient/releases [3]: https://github.com/PeaceFounder/PeaceFounderClient/blob/main/qml/Bridge https://github.com/PeaceFounder/PeaceFounderClient/blob/main... [4]: https://github.com/PeaceFounder/PeaceFounderClient/blob/cf9d831191475159d8280c309d9f786b91018bac/src/PeaceFounderClient.jl#L120 https://github.com/PeaceFounder/PeaceFounderClient/blob/cf9d...
- notyoutube 3y agoAnd an interesting project to boot! Thanks for sharing
- sircastor 3y agoIt was basically this - and to be clear this is not a shortcoming of QML. As you said, splitting the logic layer from the UI is a good idea - but the choice for us to be building apps in QML without a logic layer under it required a lot of weird solutions that could've been easily addressed if we'd been doing C++ and Qt. But our team were Javascript developers, the team we were partnering with were Qt devs, and someone had negotiated this solution and we did the work.