3

I have an application implemented in Qt with some c++ and python integrated modules (machine learning, signal processing, etc.) with the following basic characteristics:

  1. Internal multi-threading modules that may run parallel (QThread)
  2. Provide visualization characteristics like 2D plots (not send images) via Qt widgets, e.g., QwtPlotZoomer, QwtPlotMarker, QGraphicsRectItem, QwtPlotCurve.

My goal is to provide the already implemented application characteristics of the server running application via a web browser application with multiple users-observers. I have made some research and spotted some possible solutions (Qt WebGL, Qt for Assembly, Wt) on the following links (link, link, link, and link) but as an unexperienced web application developer I am not entirely sure which of these or alternative and preferable C++ modules to use.

Please provide suggestions on which web development library to use based on characteristics like the maturity, capabilities, easy of use, and the maturity (flexibility with Qt widgets) but also take into account my application

PS: I am experienced in C++ and python not Java and Javascript.

3
  • This also depends on how you want to handle your logic. Should all code run on the server, and clients only See the result? (Basically a remote window) Or can/should the code be at least partially executed on the browsers as well. Tell me that and I will give you an answer Commented Feb 11, 2019 at 9:35
  • @Felix thanks for the interest. Basically, the operations I want to execute are machine learning algorithms so as far as I can Image a server execution of the heavy processes has to take place. I do not know in this point If some less important and less heavy modules have to be executed on the browser. Thus, the app will broadcast machine learning results in the remote browser and it will be displayed ( fancy plots, charts, text). Commented Feb 11, 2019 at 19:40
  • similar: Is it possible to create web application using Qt? Commented Sep 16 at 22:41

2 Answers 2

7

If you want to make an application that can server multiple clients with Qt, there are 3 general options:

The Qt WebGL Platform Plugin

This one will create a pure server-sided implementation and simply display the GUI remotely in the browser. This appears to be the simplest approach, but has a few limitations and drawbacks:

  1. Only one client can be servered at a time. This can be worked around by creating a "spawner" application that waits for incomming traffic and starts a new instance per connected client. However, this requires quite some extra logic and is resource heavy
  2. High network load. Especially interactive GUIs can draw up to 40MBit/s per client!
  3. No client logic. It is simply not possible to add client code in this setup

All together this method was never designed for such a use case. It is meant to be used as GUI for headless devices or maintanance access. I would not recommend to use it.

Server Application + Qt for WebAssembly

Split your application in two: A server application and a client application. The client application with Qt for WebAssembly. Communication between the two can be done with QtWebSockets, QtRemoteObjects or other Network-IPC solutions.

This gives you the advantage of having to use only one language, and makes IPC very easy, as both sides use Qt. Also, calcuation-heavy tasks are much more efficient in WASM. However Qt for WebAssembly is still in a technical preview state and thus not stable yet. For example it does not support multithreading or TCP/IP sockets yet. Also, not all enddevices support WASM as of now.

Server Application + HTML WebApp

The last approach is to mix technologies. Use a Web-Framework like Cutelyst to create a Qt-based webserver and serve a classical HTML website with it. You can use QtWebChannel to transfer data between your Qt-Server and the HTML-Client easily.


The decision between a WASM and a HTML client is up to you. Using WASM might be easier for you, but has it's own challanges. I would recommend you do some more reseach on both. Then create a few test applications for both solutions and compare them, to figure out which one fits your needs best

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your time answering. Sorry for my ignorance, could you please elaborate a little more on these technologies about if the final application (WASM or HTML based) will be capable to display fancy plots like the ones included in standard or extended Qt widgets?
Any frontend technology can do that. WASM for now does not work with QtWidgets, you have to use QtQuick. However, there are the QtCharts and QtDataVisualisation modules to draw plots of any kind. I have never done something like that in HTML, but there are java script/css libraries to do that out there, too.
0

Really I think there is just one main thing: If its starts crashing, you probably need one of these:

https://doc.qt.io/qt-5/qmutex.html

As to web scripting, I tend to use QWebEnginePage::runJavaScript() offering the caveat that it is not easy. The reason is, is that when injecting javascript from C++, you are dealing with a single threaded linear environment from c++, which makes the time and point of code injection very difficult. It is basically a race condition hell, and the serviceable model I ended up developing just has the script running until getting the desired result.

https://doc.qt.io/qt-5/qwebenginepage.html#runJavaScript

Meaning, that it is good to delegate tasks to robust javascript applications.

Finally, because you are working with Qt, it is good to develop a "Create everything as an API" mindset.

2 Comments

This relies on QWebEngine, a "browser as a widget", displayed inside a usual Qt desktop application. The question seems rather about using Qt to create a client-server web application that can be used by multiple clients via their web browsers.
@tanius My advice for that would be to utilize QRemoteObjects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.