Results 1 to 3 of 3

Thread: how to get html code to a string?

  1. #1

    Default how to get html code to a string?

    Hello,

    I'm trying to get html code from a webpage. I try to do this with this code:

    Qt Code:
    1. QWebView webview;
    2. webview.setUrl (QUrl("http://www.google.com"));
    3. QString s = webview.page()->mainFrame()->toHtml();
    To copy to clipboard, switch view to plain text mode 

    but the QString s obtains an empty string.., but if i do webview.show(); the page is load correctly...

    also if I do webview.setHTML("somthing html"); then i can catch this code correctly calling "toHtml()"...


    what I'm doing bad?

    thank you!

  2. #2
    Join Date
    Oct 2009
    Location
    Rennes, France
    Posts
    20
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get html code to a string?

    Hi.
    QWebView use asynchrone component, so the web page loading is make throw eventloop execution.
    So You must wait the end of load to get html code.
    You can use this signal :
    http://doc.trolltech.com/4.6-snapsho...l#loadFinished
    Contributor from the French Qt community from developpez.com
    * Forum
    * FAQ Qt ( > 100 QR)
    * Advanced and Beginner Tutorials

  3. #3

    Default Re: how to get html code to a string?

    that works !

    thank you !!

Similar Threads

  1. QFontMetrics and HTML tags
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 14th August 2008, 12:13
  2. QTextDocument Html
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2007, 12:50
  3. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  4. Replies: 1
    Last Post: 17th March 2006, 08:01
  5. [Qt 4.1]using html in QTextEdit from designer
    By patcito in forum Qt Programming
    Replies: 5
    Last Post: 16th January 2006, 22:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.