Well. The question seems to be very easy, but the result I get is different from what I expect to.
I have an app, which height depends on its content. Here is auto-resize code:
def resizeApp(self):
n = len(self.listOfWidgets)
if self.screenHEIGHT - 40 > n * 125 + 50:
self.resize(self.width(), n * 125 + 50)
self.scrollArea.resize(self.scrollArea.width(), n * 125 + 20)
else:
self.resize(self.width(), self.screenHEIGHT - 40)
self.scrollArea.resize(self.scrollArea.width(), self.screenHEIGHT - 40 - 30)
print(self.scrollArea.verticalScrollBar().isVisible())
You can see that after the resize we can define the visibility of the verticalScrollbar. Look at the app and console screenshot. We can see the that app has verticalScrollbar, but console says that it doesn't. It seems isVisible() lags a bit and tells me previous state.
For example. When I add widgets, while there is no verticalScrollbar, the console says False (verticalScrollbar is not visible). When the amount of widgets requires verticalScrollbar, scrollArea creates this verticalScrollbar, however I receive message that the verticalScrollbar is not visible. And later, after adding one more widget, I get message that the verticalScrollbar is visible.
And vice versa. When I delete widgets, I receive message that the verticalScrollbar is visible after one more widget is deleted. However it should say me "False" one step earlier.
Am I missing something?
UPDATE1. As requested, I add a working example without redundant code. You can download a zip archive from my dropbox >here<