Qt6 topics merged with General

Network communications in QML only

  • I'm using a commercial device that allows to write QML application only, in Qt 4.8.5.
    I need to find a way to communicate with the outside world but I cannot write the C++ backend, I'm stuck on ly with QML.

    There's no problem to set up a simple TCP Server (even written in Qt) to provide a REST service where my QML files can retrieve the data they need.

    Looking at the documentation of Qt4 I'm not sure if there is a QML Tcp Client class. And QtWebSocket seems to belong to Qt5 only.
    Any idea?

  • @Mark81 what about something like this? It relies on some javascript function inside QML and it's 6 years old so it should work with 4.8.5

    BTW, may I ask the name/model of the device you're working with?

  • Yeah, I always forget I can use JavaScript :-) I will try that and report back the results.
    I'm using a DX-4400 from Microtronix.

  • This post is deleted!

  • It works! Thanks for the hint.
    Last question: I have to update the values at least 5 times per second (best is 10). Of course the server is in the same LAN of the client. Do you think this is still the right approach?

    I mean, GET requests open and close the socket every time. If I had the availability of a C++ application I could open a TCP socket to be kept open. Do you see any problem to make 5-10 GET request per second continuously?

  • @Mark81 I'm not sure I can help you now regarding performance of repeated requests, but now that you know you can run some javascript on the device, could it be possible you try socket.io for instance by importing a javascript module in QML?

  • Of course. I will try that. It was just a thought about, slightly off-topic I have to say. Apologize for that.
    Your hint was very useful indeed. Thanks.

Log in to reply