[PyQt] Scrollbars appearing when not needed?

Chris Wood c.c.wood at gmail.com
Mon May 19 10:29:46 BST 2014

On 17/05/2014 15:05, David Boddie wrote:
> On Fri, 16 May 2014 14:26:50 +0100, Chris Wood wrote:
>> On 16/05/2014 11:54, David Boddie wrote:
>>> On Thu May 15 16:42:06 BST 2014, Chris Wood wrote:
> [...]
>>>>          frame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
>>>>          frame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
>>> What is frame? Is it the QWebView?
>> Yes - it is the QWebView
> OK.
>>>> 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?
>> No - they disappear totally and don't appear when the QMainWindow is
>> resized.
> Is that the desired behaviour, or would you prefer it if they appeared when
> the window is too small?
For the current application, because of the contents of the QWebView 
frame, 202x202 is the minimum size I'd ever want - the downside is that 
if left-mouse button is clicked, a context menu appears which extends 
below the view, and scrollbars don't appear so that the menu can be 
seen. I know that a) I could allow scrollbars to appear on a left-click 
and b) having such a large context menu is probably a bad idea (although 
it's a 3rd party library - I'm probably going to do something about it 
to make the functions currently only available via the menu more accessible)

>>> 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?
>> Unless there's something else I've missed, I'd have thought the fact
>> that the border appears (and that there is no whitespace around it) does
>> confirm thatthe QWebView is 202 x 202 pixels?
> It was just something I would check if I was experiencing a similar problem.
> There's no guarantee that the view would be exactly that size unless you
> explicitly give it a fixed size. At least, I would be concerned about other
> widgets that the view is sharing the space with in the same parent widget.
> As for the scrollbars appearing by default, even if you have enough space
> to show the contents of the view: it may be the normal behaviour but I doubt
> it is documented. The workaround you used - disable the scrollbars - may be
> good enough to use if you can guarantee that the view won't be smaller than
> 202 x 202 pixels. You could also set the minimum size to ensure that will be
> the case.
I'm slightly relieved that the workaround I found is the most correct; 
it's slightly frustrating that there is undocumented behaviour in 
Qt/PyQt/Qt Designer
> David
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

More information about the PyQt mailing list