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. Manage Web Content without QWebChannel

Manage Web Content without QWebChannel

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 919 Views 2 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.
  • L Offline
    L Offline
    LovelyGrace
    wrote on last edited by
    #1

    Can I manipulate a web page without using QWebChannel? Just in case it's possible, and how am I going to do that?

    For example, how can c++ detect if a button from a web page was clicked?

    raven-worxR 1 Reply Last reply
    0
    • L LovelyGrace

      Can I manipulate a web page without using QWebChannel? Just in case it's possible, and how am I going to do that?

      For example, how can c++ detect if a button from a web page was clicked?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @LovelyGrace
      Not with QtWebEngine.
      With QtWebkit (removed since Qt 5.6) its possible, but you will have to build the module yourself.

      --- 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
      • L Offline
        L Offline
        LovelyGrace
        wrote on last edited by
        #3

        Even if I use QWebEnginePage::runJavaScript()? Though I tried but it's not working. So in other words we manage the javascript on the web without qwebchannel?

        And what do you mean to build my own module?

        raven-worxR 1 Reply Last reply
        0
        • L LovelyGrace

          Even if I use QWebEnginePage::runJavaScript()? Though I tried but it's not working. So in other words we manage the javascript on the web without qwebchannel?

          And what do you mean to build my own module?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @LovelyGrace said in Manage Web Content without QWebChannel:

          Even if I use QWebEnginePage::runJavaScript()?

          you can manipulate the DOM, but you won't be able to make a dynamic connection (or notification upon changes) back to C++.

          And what do you mean to build my own module?

          As i said QtWebkit isn't part of Qt releases post 5.6.
          But it is still available (and more or less unmaintained) in the repositories: http://code.qt.io/cgit/qt/qtwebkit.git/

          --- 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
          • L Offline
            L Offline
            LovelyGrace
            wrote on last edited by
            #5

            By manipulating the DOM, can i get the data from the web page? like for example, on the login page, when user clicked the login, the c++ can detect the username of the users using QWebEnginePage::run JavaScript()?

            QWebEnginePage *page = new QWebEnginePage;
            page = view.page();
            page->runJavaScript(QString("document.getElementById('username').value"), [](const QVariant& res) {
            qDebug() << "Username = " << res.toString();
            });

            Ive tried the codes above but i get this error: [0129/141308:INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'value' of null", source: (1)
            Username = ""
            js: Uncaught TypeError: Cannot read property 'click' of null
            [0129/141308:INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'click' of null", source: (1)
            js: The key "" is not recognized and ignored.

            raven-worxR 1 Reply Last reply
            0
            • L LovelyGrace

              By manipulating the DOM, can i get the data from the web page? like for example, on the login page, when user clicked the login, the c++ can detect the username of the users using QWebEnginePage::run JavaScript()?

              QWebEnginePage *page = new QWebEnginePage;
              page = view.page();
              page->runJavaScript(QString("document.getElementById('username').value"), [](const QVariant& res) {
              qDebug() << "Username = " << res.toString();
              });

              Ive tried the codes above but i get this error: [0129/141308:INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'value' of null", source: (1)
              Username = ""
              js: Uncaught TypeError: Cannot read property 'click' of null
              [0129/141308:INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'click' of null", source: (1)
              js: The key "" is not recognized and ignored.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @LovelyGrace
              looks like there is no element with an id of username
              Probably you are executing your code too early (before the page has been loaded)?

              --- 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
              • L Offline
                L Offline
                LovelyGrace
                wrote on last edited by
                #7

                how am I going to fix it?

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  LovelyGrace
                  wrote on last edited by
                  #8

                  yes i think it was executed before the page was finished loading.

                  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