Results 1 to 4 of 4

Thread: QWebView - Showing portion of a webpage.

  1. #1
    Join Date
    Jun 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QWebView - Showing portion of a webpage.

    Hi everybody,

    Can someone tell me if there is a way to show just a portion of a web page using a qwebview? For example, if I just want to see the Google logo, not the entire page... (This is just an example, it is not what I'm trying to do).

    Regards,
    Javier.
    Last edited by TemplarKnight; 5th October 2011 at 19:14. Reason: Forget to configure the notifications.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView - Showing portion of a webpage.

    It all depends what you want to do. If you wish to see a particular image from the website then the easiest way is to find its url and download it. If you want a particular tag contents, then QWebElement::render() is something you should look at. If you want a part of the website based on geometry then have a look at QWebFrame::render(). If you want the part of the page to be interactive then well... it's not that easy
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    TemplarKnight (6th October 2011)

  4. #3
    Join Date
    Jun 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWebView - Showing portion of a webpage.

    Hi,

    Thanks for your reply. I ended up with the dirtiest trick ever, but it works for me this way, and do what I want... hehe

    After the page load has ended, I simple move the scrollbars to the position I wanted, and then just hide them...

    Qt Code:
    1. ui->webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, 900);
    2. ui->webView->page()->mainFrame()->setScrollBarValue(Qt::Horizontal, 640);
    3.  
    4. ui->webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    5. ui->webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    To copy to clipboard, switch view to plain text mode 

    And that's all!

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView - Showing portion of a webpage.

    Kind of ineffective if one clicks on the webpage and uses cursor keys to move the view or resizes the window or zooms the webpage.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QWebview not showing images
    By manojmka in forum Qt Programming
    Replies: 27
    Last Post: 17th July 2012, 00:22
  2. Cannot open webpage with QWebView
    By szyema in forum Qt Programming
    Replies: 10
    Last Post: 27th February 2012, 11:04
  3. Replies: 6
    Last Post: 16th June 2011, 16:03
  4. QWebView showing blank pages.
    By gontham in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2010, 11:02
  5. printing QWebView before showing in Dialog
    By Grisu in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2008, 13:20

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.