Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Help with QtWebPage/Frame please

Help with QtWebPage/Frame please

Scheduled Pinned Locked Moved Qt WebKit
3 Posts 2 Posters 1.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.
  • U Offline
    U Offline
    us0rman
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      sl.sy.ifm
      wrote on last edited by
      #2

      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
      0
      • U Offline
        U Offline
        us0rman
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved