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. Call C++ method from a javascript (html) loaded on QtWebView (android)
Forum Updated to NodeBB v4.3 + New Features

Call C++ method from a javascript (html) loaded on QtWebView (android)

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 3 Posters 4.2k Views 1 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.
  • R Offline
    R Offline
    re.tf
    wrote on last edited by
    #1

    Hi All,

    Have any way to call C++ method from a javascript on a page, in QtWebView (android)

    I want develop my UI in html5, load it on QtWebView , and buttons on my html (javascript) fire native code in c++ (e.g: start camera);

    Or fire some QML that will fire native C++ code. Or any other way?

    Have any way to achieve this?

    And what is Qt WebEngine?

    I am using QT 5.4

    Thanks for help

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      bq. Have any way to call C++ method from a javascript on a page, in QtWebView (android)

      Yes. Check out "addToJavaScriptWindowObject":http://doc.qt.io/qt-5/qwebframe.html#addToJavaScriptWindowObject. Just declare the functions as public slots. An example "here":http://doc.qt.io/qt-5/qtwebkitexamples-webkitwidgets-imageanalyzer-example.html.

      bq. Or fire some QML that will fire native C++ code. Or any other way?

      QML would be completely different approach than using QtWebkit.
      For detailed exaplantion of interaction of C++ and QML, check "qtqml-cppintegration":http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html.

      bq. And what is Qt WebEngine?

      Its a new web rendering engine that is planned to replace QtWebKit in Qt. It is based upon Google Chromium browser.

      157

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        [quote author="re.tf" date="1422286520"]
        Have any way to call C++ method from a javascript on a page, in QtWebView (android)[/quote]

        i doubt that this is possible. Since QtWebView module is just a wrapper for the mobile platform's native web view. And there is no way to "communicate":https://qt.gitorious.org/qt/qtwebview/source/ea443a6960316d5070c1a3a5dbe21037a96ff7e4:src/imports/plugins.qmltypes#L4 very much with this view (yet).

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          [quote author="raven-worx" date="1422346835"][quote author="re.tf" date="1422286520"]
          Have any way to call C++ method from a javascript on a page, in QtWebView (android)[/quote]

          i doubt that this is possible. Since QtWebView module is just a wrapper for the mobile platform's native web view. And there is no way to "communicate":https://qt.gitorious.org/qt/qtwebview/source/ea443a6960316d5070c1a3a5dbe21037a96ff7e4:src/imports/plugins.qmltypes#L4 very much with this view (yet).

          [/quote]

          Ahh.. Right. That method wont work on android as it is QWebView based and it is not supported on Android. Sorry for that. Even "QtWebEngine":http://qt-project.org/wiki/QtWebEngine#5405d8a903c83e89cb649f1b518ef1be won't be of use.

          157

          1 Reply Last reply
          0
          • R Offline
            R Offline
            re.tf
            wrote on last edited by
            #5

            Well, i need this to build integration between html5 and C++. Any other workaround?

            For sample, in case of instagram, I think that all UI is HTML5 and when you click in camera it fire camera in native way.

            This is true?
            How instagram achieve this?

            I thought that 'Instagram' was build in QT! Not?

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              May be "Qt WebChannel":http://doc.qt.io/qt-5/qtwebchannel-index.html. This "article":http://www.kdab.com/qt-webchannel-bridging-gap-cqml-web/ is a good read.

              157

              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