Results 1 to 3 of 3

Thread: QWebView Extract Information

  1. #1
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWebView Extract Information

    I have a QWebView that loads a page that has some javascript which modifies the document on the fly. AKA:
    Qt Code:
    1. document.getElementByID("displayWindow").innerHTML = "Somegeneratedtext";
    To copy to clipboard, switch view to plain text mode 
    Is there a way to for my Qt program to look at the modified page, and capture this changed text in say, a QString, perhaps like QTextCursor?

  2. #2
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView Extract Information

    From what it looks like, I could use QWebPage * page () to get the page, then QWebFrame * currentFrame () to get the singular frame that appears.

    From there I can use QVariant evaluateJavaScript ( const QString & scriptSource ) to "inject" a script that will check the innerhtml, or i could use toHtml () or toPlainText () and parse out the pieces of the web page that I was interested in.

    Does this sound like the right direction to go? or is there an easier way?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView Extract Information

    For now there is no direct access to page's DOM tree, so you have to use JavaScript.

Similar Threads

  1. QWebView - retrieving information?
    By lamera in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2008, 17:53
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

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.