PDA

View Full Version : Fitting QWebView to content



Sölve
7th September 2010, 00:25
Hello.

When I writing my weather "gadget" I met some trouble with size of QWebView. My program uses QWebView as main Widget and I want to fit window to content size. I set html and body size, but when I determining width and height of window to size of body, I can see scrollbars. I reading size with jQuery. Only way to hide them is set "overflow: hidden" in CSS section for body. Body and html sizes are 230x188px. How to fix it?

This is piece of code, where I set window and viewport size:


this->page()->mainFrame()->evaluateJavaScript(jQSource);
int width = this->page()->mainFrame()->evaluateJavaScript("$('html').width()").toInt();
int height = this->page()->mainFrame()->evaluateJavaScript("$('html').height()").toInt();
this->page()->setViewportSize(QSize::QSize(width, height));
resize(width, height);


I'm tried with this, but detected size was 800x600px:


this->page()->setViewportSize(this->page()->mainFrame()->contentsSize());
Thanks in advance.