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. Creating a frame from HTML and parsing it
QtWS25 Last Chance

Creating a frame from HTML and parsing it

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.3k 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.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    Hello
    I'd would like to parse some HTML in -QT- Qt. I've found a lot of tutorials, but I have a hard time understanding one detail:

    @ frame->setHtml(HTML);
    QWebElement document = frame->documentElement();
    QList<QWebElement> imgs = document.findAll("table");
    @

    What does "frame" refer to? I guess it's to a "QWebFrame" object, but how should I handle this? I have some HTML stored as a
    QString, and would like to parse this, but:

    @QWebFrame *frame = new QWebFrame();@

    does not work... How can I create a frame and set the HTML to it? Thanks!
    Richard

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KA51O
      wrote on last edited by
      #2

      I think you can't, you have to create a page and access its frame like this:

      @QWebPage page ();
      page.mainFrame()->setHtml(htmlString, QUrl::fromLocalFile("C:\someFolder");
      @

      In case you want to display the html I'd recommend you use a QWebView
      @QWebView* webView = new QWebView (parent);
      webView->setHtml(htmlString, QUrl::fromLocalFile("C:\someFolder");
      QWebElementCollection image = webView->page()->mainFrame()->findAllElements("img");
      if(image.count() > 0)
      {
      image.at(0).setAttribute("src", filePathString);
      }
      @

      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