Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Hints for web-application with Qt5 server-side code
Forum Updated to NodeBB v4.3 + New Features

Hints for web-application with Qt5 server-side code

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 4 Posters 1.7k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I wonder what the best approach for a web-application with these requirements:

    • needs server-side code to push content
    • the content itself is already retrieved by a Console Qt5 application
    • needs a async channel to exchange data (i.e. websockets) along with the common submit pattern

    No problems with the last two points.
    About the first one, I have few questions:

    1. as far as I know Qt5 is not usable to write server-side code directly. But if I write my web application using, say, PHP how would I exchange data with my Qt application?

    2. if this approach is still valid, who should handle the web socket communication? PHP or Qt5?

    Any idea is very appreciated. Of course feel free to ask further details!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      1. You likely want to take a look at the cutelyst project.
        If you are talking about e.g. a REST service that should be consumed by the client, the fact that it is implemented in PHP, C++, Python or any other language doesn't play any role in terms of exchanging data. That's defined by the standard you want to use, not the language you used to implement it.

      2. What approach ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

        I meant the approach described in the previous line: write the server-side code in PHP and exchange data between the Qt5 console application to retrieve/send data.

        No, I'm not talking about a REST service.
        I try with an example, then I read the cutelyst project link.

        There is a field with several machines (PLCs). They are connected to an embedded board using RS485 serial.
        On the embedded board runs my Qt5 console application that handles all the modbus communications with the PLCs, stores their data into an SQL database, writes logs, sends TCP telemetry to custom services, etc...

        Now I need to write a web application - I mean dynamic HTML pages - to interact with my application. For example a table to read and update the parameters, an overview to see the state of each PLCs, etc... Of course all this information are available inside my Qt5 Console application.

        I'm used to write such a web application using PHP on server-side and HTML5/js on client-side.
        But usually the whole application is created in PHP! In this scenario all the data is inside the Qt5 application (real-time data) and in the SQL database (settings, past data) and I'm not sure how to exchange this information between PHP and Qt5. For example I need to:

        • retrieve the settings value to create a table with their value
        • receive the new value of a settings via websocket and update it
        • receive the whole set of parameters via a form submit and update them
        • display the real-time data on the web-page
        • ...
        J.HilkJ 1 Reply Last reply
        0
        • M Mark81

          I meant the approach described in the previous line: write the server-side code in PHP and exchange data between the Qt5 console application to retrieve/send data.

          No, I'm not talking about a REST service.
          I try with an example, then I read the cutelyst project link.

          There is a field with several machines (PLCs). They are connected to an embedded board using RS485 serial.
          On the embedded board runs my Qt5 console application that handles all the modbus communications with the PLCs, stores their data into an SQL database, writes logs, sends TCP telemetry to custom services, etc...

          Now I need to write a web application - I mean dynamic HTML pages - to interact with my application. For example a table to read and update the parameters, an overview to see the state of each PLCs, etc... Of course all this information are available inside my Qt5 Console application.

          I'm used to write such a web application using PHP on server-side and HTML5/js on client-side.
          But usually the whole application is created in PHP! In this scenario all the data is inside the Qt5 application (real-time data) and in the SQL database (settings, past data) and I'm not sure how to exchange this information between PHP and Qt5. For example I need to:

          • retrieve the settings value to create a table with their value
          • receive the new value of a settings via websocket and update it
          • receive the whole set of parameters via a form submit and update them
          • display the real-time data on the web-page
          • ...
          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @mark81

          take a look at this website, it deals with Qt and integrating Web content
          https://doc.qt.io/qt-5/topics-web-content.html

          since last update there's also now Qt for WebAssembly which could be interesting for your case ?


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          M 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @mark81

            take a look at this website, it deals with Qt and integrating Web content
            https://doc.qt.io/qt-5/topics-web-content.html

            since last update there's also now Qt for WebAssembly which could be interesting for your case ?

            M Offline
            M Offline
            Mark81
            wrote on last edited by Mark81
            #5

            @j-hilk Thanks for the link. I think these classes are very useful for communications between the client and the server.
            The only point that is still missing is the server-side code to generate dynamic content.

            You have, say 1200 parameters (well, the actual application has more) to display and let the user to edit them.
            In PHP you can query the data from the database, page the records, write the HTML code on the fly and push to the client.

            How would you do the same with Qt5?
            Or, if it's not worth to, how to pass the data to the PHP scripts so they can create the dynamic web-page?

            J.HilkJ 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              One thing I'm not sure you are not over-engineering: it looks like you want to build a big application that does everything.

              You already have the backend running with your console application. Then why not just plug the frontend on the same database and let it run on its side whatever the technology you prefer ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              1
              • SGaistS SGaist

                One thing I'm not sure you are not over-engineering: it looks like you want to build a big application that does everything.

                You already have the backend running with your console application. Then why not just plug the frontend on the same database and let it run on its side whatever the technology you prefer ?

                M Offline
                M Offline
                Mark81
                wrote on last edited by
                #7

                @sgaist said in Hints for web-application with Qt5 server-side code:

                Then why not just plug the frontend on the same database and let it run on its side whatever the technology you prefer ?

                Because as said not all data is stored into the db.
                Most information are available in real-time only. I don't think is a good idea to continuously update hundreds of records every second 24/7...

                Pablo J. RoginaP 2 Replies Last reply
                0
                • M Mark81

                  @sgaist said in Hints for web-application with Qt5 server-side code:

                  Then why not just plug the frontend on the same database and let it run on its side whatever the technology you prefer ?

                  Because as said not all data is stored into the db.
                  Most information are available in real-time only. I don't think is a good idea to continuously update hundreds of records every second 24/7...

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #8

                  @mark81 said in Hints for web-application with Qt5 server-side code:

                  I don't think is a good idea to continuously update hundreds of records every second 24/7...

                  Just change the update frecuency :-)

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  1
                  • M Mark81

                    @sgaist said in Hints for web-application with Qt5 server-side code:

                    Then why not just plug the frontend on the same database and let it run on its side whatever the technology you prefer ?

                    Because as said not all data is stored into the db.
                    Most information are available in real-time only. I don't think is a good idea to continuously update hundreds of records every second 24/7...

                    Pablo J. RoginaP Offline
                    Pablo J. RoginaP Offline
                    Pablo J. Rogina
                    wrote on last edited by Pablo J. Rogina
                    #9

                    @mark81 said in Hints for web-application with Qt5 server-side code:

                    Because as said not all data is stored into the db.

                    Have you consider the MQTT protocol? Qt does support it.

                    Your Qt console app (talking to the devices/sensors) will be a publisher to a MQTT broker server, and then your web-based GUI app (very like running in the same host as the MQTT broker) will be a subscriber to whatever topics you want to display online...

                    Upvote the answer(s) that helped you solve the issue
                    Use "Topic Tools" button to mark your post as Solved
                    Add screenshots via postimage.org
                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    4
                    • M Mark81

                      @j-hilk Thanks for the link. I think these classes are very useful for communications between the client and the server.
                      The only point that is still missing is the server-side code to generate dynamic content.

                      You have, say 1200 parameters (well, the actual application has more) to display and let the user to edit them.
                      In PHP you can query the data from the database, page the records, write the HTML code on the fly and push to the client.

                      How would you do the same with Qt5?
                      Or, if it's not worth to, how to pass the data to the PHP scripts so they can create the dynamic web-page?

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @mark81 said in Hints for web-application with Qt5 server-side code:

                      @j-hilk Thanks for the link. I think these classes are very useful for communications between the client and the server.
                      The only point that is still missing is the server-side code to generate dynamic content.

                      You have, say 1200 parameters (well, the actual application has more) to display and let the user to edit them.
                      In PHP you can query the data from the database, page the records, write the HTML code on the fly and push to the client.

                      How would you do the same with Qt5?
                      Or, if it's not worth to, how to pass the data to the PHP scripts so they can create the dynamic web-page?

                      I'm sorry, that is not really my forte. I know classes exists, So I linked them, but I haven't used them myself yet


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved