Solved Udp and Tcp sockets with QML
I recently got a requirement/suggestion for moving a QT C/C++ GUI to QML GUI. I found that the application uses TCP and UDP sockets. I also realized that QML does not provide a direct UDP/TCP class.
I found a couple of ways to do it:
- Integrate QML code into QT code. [http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html]
- Use a user built QML code [which does the same thing as above but its a qml class] [https://github.com/jemc/qml-sockets]
I want to know the best way to do it. Any help would be appreciated.
Basically whichever is easier for you to do. Normally, people focus on doing GUI in QML and keeping business logic in C++ - this has 2 major benefits:
- deep separation between UI and logic, which helps later in e. g. changing UIs, styling, different UIs for mobile and desktop apps etc.
- C++ does what it is best at (performance, interfacing with databases, other libraries etc.), and QML does what it's best at (beautiful and fluid GUIs)
Since you already have the app written in Qt C++, I'd say it will be more convenient for you to only rewrite the GUI parts in QML, and leave the current code for the rest. However, if the current code is of poor quality, you may consider rewriting the whole thing. Hard to say.
Thanks for the answer. I can't find the way to mark this thread as solved though. Thanks again.