Make a complex application with high performance
I am using qt since few years ago now, and I discovered QtQuick last week.
I am really surprised by how it is simple to write quickly little program :D.
So I have few questions. I have an idea to develop applications, and the idea is explained as follow:
- All GUI Widgets should be developped using QML
- All little slots could be written in JS
- Complexe funtion should be write in C++ using QThread
What do you think about this approach.
Should we always use threads to have better performance instead of timer because timer is launched in the same thread?
Do you think should we avoid to use WorkerScript (because it is difficult to share variable between threads and because each thread own his own JS Engine) ?
Sorry for my english...
Hi and welcome to devnet,
Before using threads, what complex functions do you have in mind ?
Hello and thanks for welcoming :).
It was just a question, I don't have any project right now, it was just an idea to develop applications later.
But for example, we could find a function which is going to search something in a database, or a file :). Or compute an equation :).
The usual paradigm is indeed to keep intensive operations in C++ and the GUI in QML. Then you should also analyze what kind of processing you will need. Sending request to a database is likely to essentially trigger work outside the GUI thread anyway since the DBs are usually on remote servers so threads might not be required.
You should also take into account whether you'll be doing GPU work, that will influence your application's architecture.
Thanks for your answer,
So, you told "DBs are usually on remote servers, so threads might not be required".
Yes, but when we did the query, it could take a long time, and block the GUI thread, that's why I had the idea to use a thread ^^.
That's the reason of the "might" ;)
Benchmark and testing should be done to see what's needed for a given application. Qt's asynchronous nature helps to avoid the use of threads for many things.
Yeah I see^^.
Thanks a lot for your answers guy :).