Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Call a function of the program from a website, is it possible?
QtWS25 Last Chance

Call a function of the program from a website, is it possible?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 3.5k Views
  • 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    Let's say both application installed and website has a login form..
    Is it possible somehow from the website send a message to the application to do something specific ( call a function )..

    As seen from this link (http://doc.qt.digia.com/qt/examples-network.html), this must be possible , but could u help me by giving some tips-links?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Madon
      wrote on last edited by
      #2

      Hello,

      Maybe this link help you : http://doc.qt.digia.com/stable/webkit-formextractor.html

      A bit of reading it can not hurt http://beej.us/guide/bgnet/

      Regards

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        I cannot run the example,

        bq. Could not copy file '//boot/System.map-3.5.0-17-generic' to '/home/citybong/formextractor/boot/System.map-3.5.0-17-generic'.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          It depends: A website can run arbitrary code on the web server. Of course that code can try to talk to an application via the network. Most websites routinely do so: They access a SQL database somewhere on the network.

          So if you can put code onto the web server you can indeed trigger your application to actually do something. But for this the host running the application must be accessible to the webserver. Most people connecting to your server won't be: They are behind proxies, using NAT, are firewalled, etc.

          If you are using your own Qt webkit widget you can expose objects to the JS engine that it can work with and access those via JS delivered by the web site. This will of course not work when the user is using a normal stand-alone browser. Those will not allow your site to trigger code not considered safe by the browser (with the exception of plugins of course).

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leon
            wrote on last edited by
            #5

            I will buy my domain&hosting site, so i am able to do anything i want to the site..

            The only thing i can think to call a function of the program from a website, is from the website to change a .txt file and basically the program downloads that .txt file every second.. But wouldn't that consume a lot bandwidth to the user's network?

            "Tobias Hunger" is it possible to explain a bit more the easiest way to do something else than the txt thing? I mean for example about the Js engine, could u explain that more detailed?

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              Download a file every second? Are you mad? Seriously: Waking up a laptop every second, making sure the wireless LAN is powered up and the HDD spinning is a surefire way to make sure the batteries will not last long. You should add some expensive to compute hash to make sure the txt file was downloaded correctly. That should get you pretty close to finding out how long your battery is going to last in a worst case scenario:-)

              Sorry, I am no web expert... no idea how all that new AJAX stuff is done on the server side. Putting a QObject into a qwebpage was pretty trivial when I last tried. I don't remember the details though, so read the docs yourself.

              You might want to investigate a jabber or IRC (instant messaging) for the communication, too.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Madon
                wrote on last edited by
                #7

                Leon,
                It seems that you do not take it the right way.

                What do you do? An IRC client, network game, consume a Web service, a pilot project for a third party application, to enjoy

                What is the purpose of the software is complete?

                PS : I speak very little English, so excuse.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MuldeR
                  wrote on last edited by
                  #8

                  [quote author="Tobias Hunger" date="1353934819"]So if you can put code onto the web server you can indeed trigger your application to actually do something. But for this the host running the application must be accessible to the webserver. Most people connecting to your server won't be: They are behind proxies, using NAT, are firewalled, etc.[/quote]

                  He could solve this the other way around: Have the local application connect to some application running on the server. The server-side application would open a port and wait for incoming connections from the client-side application. Whether the client application will use polling to get informed about new tasks it is supposed to do or whether the server will push commands over a permanent connection to the client, is up to his decision...

                  My OpenSource software at: http://muldersoft.com/

                  Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                  Go visit the coop: http://youtu.be/Jay...

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Leon
                    wrote on last edited by
                    #9

                    I don't know do i sound proffesional in internet programming and u think that with what u said i will be able to achieve what i want... ? :/

                    bq. Have the local application connect to some application running on the server. The server-side application would open a port and wait for incoming connections from the client-side application.

                    How to do that? I don't want all the steps, just at least some links that could help me.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dcbasso
                      wrote on last edited by
                      #10

                      I make something like this:

                      On page (JS):
                      @
                      onclick="sender.clicked( 1 );"
                      @

                      On Qt:
                      @
                      //On Load Page:
                      ...
                      ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("sender", this);
                      ...

                      void WebPage::clicked(int codigo)
                      {
                      ...
                      }
                      @

                      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