PDA

View Full Version : QWebView - Showing portion of a webpage.



TemplarKnight
5th October 2011, 19:12
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.

wysota
6th October 2011, 01:00
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 :)

TemplarKnight
6th October 2011, 15:03
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...



ui->webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, 900);
ui->webView->page()->mainFrame()->setScrollBarValue(Qt::Horizontal, 640);

ui->webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
ui->webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);


And that's all! :D

wysota
7th October 2011, 01:11
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.