Can not move horizontalScrollBar to the rightmost side
-
class PP(QMainWindow): def __init__(self): super().__init__() loader = QUiLoader() self.main_ui = loader.load('test.ui') self.setCentralWidget(self.main_ui) self.main_ui.pushButton.clicked.connect(self.add_l) self.resize(500, 150) self.show() def add_l(self): print(self.main_ui.scrollArea.horizontalScrollBar().maximum()) self.main_ui.horizontalLayout_2.addWidget(QLabel(' ***aaaaa** ')) print(self.main_ui.scrollArea.horizontalScrollBar().maximum()) print('--------------') self.main_ui.scrollArea.horizontalScrollBar().setValue(9999) if __name__ == '__main__': app = QApplication() ui = PP() app.exec()I'm using the above code to do a test.
The 'test.ui' is a very simple UI created by Qt Designer.

Every time I push the button, a newQLabelis add to the layout. And at the same time, I try to move the horizontalScrollBar to the rightmost side. But it failed. There's always some space left at right.

The max value of the horizontalScrollBar did not change after I add aQLabel.
