Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QWebFrame and QWebElementCollection equivalences?

QWebFrame and QWebElementCollection equivalences?

Scheduled Pinned Locked Moved Solved QtWebEngine
4 Posts 3 Posters 1.8k 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.
  • V Offline
    V Offline
    victl
    wrote on last edited by victl
    #1

    Hello,

    I'm currently porting a dictionary app (GoldenDict to be precise) from QtWebKit to QtWebEngine. That app used QWebFrame and QWebElementCollection for which I couldn't find equivalences.

    1. QWebFrame

    I read from QtWebEngine docs:

    In Qt WebEngine, frame handling has been merged into the QWebEnginePage class. All child frames are now considered part of the content, and only accessible through JavaScript.
    

    That means iframe elements could only be manipulated via JavaScript. But it seems QtWebKit have exposed this functionality via C++ API, which I think is far more convenient to use.

    Yet, I found this snippet from Qt 5.9.2's example demobrowser:

    #if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
    // ...
    QList<QWebEngineFrame*> frames;
    frames.append(mainFrame());
    // ...
    #endif
    

    QWebEngineFrame is actually not implemented in QtWebEngine, and QWEBENGINEPAGE_UNSUPPORTEDCONTENT is not defined in that example project either. Does it means QWebEngineFrame is planned to be added into QtWebEngine in future releases?

    1. QWebElementCollection

    To me, QWebElementCollection looks very like that it's a DOM model with C++ API, you use it to iterate through the DOM tree and get what you want, so sweat!

    But I couldn't do that in QtWebEngine, am I right?

    To summarise, I had a feeling that with QtWebKit, you have fine granule control over individual elements of a web page. But with QtWebEngine, most functionalities were packaged into the underlying Chromium foundation, and you have to rely on JavaScript a lot, which is a burden for me as a C++ programmer who is not so familiar with JavaScript.

    And that made me come up with a third question:
    3. If I have to manipulate HTML elements with JavaScript, how do I transfer results back to C++? Such as iterate through some group of elements and query for some attributes?

    I'd apologize if I didn't compose those questions well, since I've just started to use QtWebEngine or QtWebkit very recently. Hope you would forgive me. And thank you for any help.

    raven-worxR 1 Reply Last reply
    0
    • V victl

      Hello,

      I'm currently porting a dictionary app (GoldenDict to be precise) from QtWebKit to QtWebEngine. That app used QWebFrame and QWebElementCollection for which I couldn't find equivalences.

      1. QWebFrame

      I read from QtWebEngine docs:

      In Qt WebEngine, frame handling has been merged into the QWebEnginePage class. All child frames are now considered part of the content, and only accessible through JavaScript.
      

      That means iframe elements could only be manipulated via JavaScript. But it seems QtWebKit have exposed this functionality via C++ API, which I think is far more convenient to use.

      Yet, I found this snippet from Qt 5.9.2's example demobrowser:

      #if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
      // ...
      QList<QWebEngineFrame*> frames;
      frames.append(mainFrame());
      // ...
      #endif
      

      QWebEngineFrame is actually not implemented in QtWebEngine, and QWEBENGINEPAGE_UNSUPPORTEDCONTENT is not defined in that example project either. Does it means QWebEngineFrame is planned to be added into QtWebEngine in future releases?

      1. QWebElementCollection

      To me, QWebElementCollection looks very like that it's a DOM model with C++ API, you use it to iterate through the DOM tree and get what you want, so sweat!

      But I couldn't do that in QtWebEngine, am I right?

      To summarise, I had a feeling that with QtWebKit, you have fine granule control over individual elements of a web page. But with QtWebEngine, most functionalities were packaged into the underlying Chromium foundation, and you have to rely on JavaScript a lot, which is a burden for me as a C++ programmer who is not so familiar with JavaScript.

      And that made me come up with a third question:
      3. If I have to manipulate HTML elements with JavaScript, how do I transfer results back to C++? Such as iterate through some group of elements and query for some attributes?

      I'd apologize if I didn't compose those questions well, since I've just started to use QtWebEngine or QtWebkit very recently. Hope you would forgive me. And thank you for any help.

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

      @victl said in QWebFrame and QWebElementCollection equivalences?:

      If I have to manipulate HTML elements with JavaScript, how do I transfer results back to C++? Such as iterate through some group of elements and query for some attributes?

      yes, DOM manipulation like with QWebElement is now only possible via JavaScript.

      See this example. Communication between C++ and JavaScript is supported via the QtWebChannel module. Not as powerful as QWebElement API was, but better than nothing.
      You need to inject a qwebchannel.js into the web-page though.
      See this for automatic injection into every QtWebEngine page.

      --- 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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Just in case, did you consider @Konstantin-Tokarev QtWebKit reboot project ?

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

        V 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Just in case, did you consider @Konstantin-Tokarev QtWebKit reboot project ?

          V Offline
          V Offline
          victl
          wrote on last edited by
          #4

          @SGaist Yes I have tried the new QtWebKit module. It all works very well. I'm looking forward to see QtWebKit 2.0 revive in future Qt releases.

          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