Reputation: 37098
I'm building a UI in QML and only working on UI logic for now, leaving application logic for later. I'm somewhat concerned about all the discussions I've strayed across relating to multithreading and asynchronous vs. synchronous code and slowness in UIs, and I want to make sure that when the application logic is added later, the QML isn't going to hold me back and slow me down by forcing single-threaded asynchronous code somehow.
Perhaps that sounds ridiculous but understand I'm brand new to non-web GUI work. I come from the lovely world of JS where all UI events are asynchronous and non-blocking.
Does anyone have any experience with this, in either python or C++?
Upvotes: 5
Views: 3806
Reputation: 7181
Here you can find almost ready-for-you answer: https://stackoverflow.com/a/16037815/867349
In few words, you can use WorkerScript at QML-side with all your functionality done in JavaScript/QML really asynchrounous (but unfortunately, I can't find the way to drop/stop that separate worker thread).
Other choice is use Qt's QThread
's. Read about Multithreading in Qt here: Multithreading Technologies in Qt | QtDoc 5.3, Threading Basics | QtDoc 5.3 and my favorite book on Qt which can be very useful in your case: Advanced Qt Programming: Creating Great Software with C++ and Qt 4). Then expose your threads to QML. Read about exposing C++ classes to QML here: Integrating QML and C++ | QtQml 5.3, Defining QML Types from C++ | QtQml 5.3.
Upvotes: 4