Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Help with QtWebPage/Frame please

    Qt WebKit
    2
    3
    1121
    Loading More Posts
    • 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.
    • U
      us0rman last edited by

      I have already seached the Forum but couldn't find any hint to where my mistake may be.
      relevant code:
      @view = new QWebView( splitter );
      view->load(QUrl("http://cplus.kompf.de/artikel/container.html"));
      QWebPage page = view->page();
      /page->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
      page->settings()->setAttribute(QWebSettings::PluginsEnabled, false);
      page->settings()->setAttribute(QWebSettings::AutoLoadImages, false);
      page->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, false);
      /
      //QWebFrame
      frame = page->mainFrame();
      QWebFrame
      frame = page->currentFrame();
      QString webHtml = frame->toHtml();
      //frame->setHtml( "<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>");
      QWebElement document = frame->documentElement();
      QWebElementCollection all = view->page()->mainFrame()->findAllElements("
      ");
      QWebElementCollection findBody = document.findAll("body");
      int c = all.count();
      int d = findBody.count();
      //QWebElement bla1 = doc.at( 1 ).firstChild();
      // QWebElement bla2 = bla1.nextSibling();
      // int c1 = doc.at(1).findAll("input").count();
      QString t1 = all.at(1).tagName();
      QString t0 = frame->toHtml();

      std::cout << t1.toLocal8Bit().data() << std::endl;
      std::cout << t0.toLocal8Bit().data();
      std::cout << webHtml.toLocal8Bit().data();@

      when i set the frame myself with frame->setHtml( "<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>"); console output returns me exactly this html code. So in this case, programm is working as expected.
      As soon as I comment it out, the frame of "http://cplus.kompf.de/artikel/container.html" should be inside webframe, but console output always gives me
      BODY
      <html><head></head><body><p>First Paragraph
      tml><html><head></head><body></body></html>

      no matter which page I try.
      I am sure that isn't really the true frame of the page.
      Sorry for my english , I would be happy if someone could help me with this webpage webframe functionallity.

      Cheers

      1 Reply Last reply Reply Quote 0
      • S
        sl.sy.ifm last edited by

        Calling QWebView::load(...) will start downloading the data asynchronously ... so, you will have to wait until loadFinished() is emitted and interact with the DOM in a slot-function

        ... and maybe your project doesn't rebuild cleanly, at least that is the only way I see how you could get the text that you commented out ...

        1 Reply Last reply Reply Quote 0
        • U
          us0rman last edited by

          Ahh thank you, loadFinished() Signal solved my problem, wonder why I didn't stumble about it somewhere else. Thanks a lot!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post