[PyQt] Scrollbars appearing when not needed?

David Boddie davidb at met.no
Fri May 16 11:54:09 BST 2014


On Thu May 15 16:42:06 BST 2014, Chris Wood wrote:

> I can provide simplified code for this if needed, but perhaps an 
> explanation will suffice for now.
> 
> I have a HTML page which has just 1 div, of size 200px x 200px, with a 1 
> px border, and all padding / margins are set to 0 in my stylesheet
> 
> I then create a QWebView widget (in Qt Designer), of size (and 
> maximumSize) 202 x 202, and embed it within a larger widget. Compiling 
> the .ui file and opening the widget causes scrollbars to be displayed 
> around the QWebWidget.  Forcing the scrollbars to be hidden,
> 
>        frame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
>        frame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)

What is frame? Is it the QWebView?

> confirms that the QWebView is the correct size, and that the border is 
> visible (i.e. the webpage is not larger than 202x202).
> 
> Why are the scrollbars appearing? Is this documented / expected behaviour?

Do they appear when you disable them using the two lines of code above?

There may be other decoration that reduces the space available to the widget
or its contents. Have you verified that the QWebView is actually 202 x 202
pixels when the application runs?

David


More information about the PyQt mailing list