Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Can not move horizontalScrollBar to the rightmost side
Forum Updated to NodeBB v4.3 + New Features

Can not move horizontalScrollBar to the rightmost side

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 201 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • feiyuhuahuoF Offline
    feiyuhuahuoF Offline
    feiyuhuahuo
    wrote on last edited by feiyuhuahuo
    #1
    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.
    56aa1e5c-347b-4f14-99c0-270c1e18ec6e-image.png
    Every time I push the button, a new QLabel is 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.
    68f1a4df-dd0b-444a-add8-290001b49390-image.png
    The max value of the horizontalScrollBar did not change after I add a QLabel.
    8cdbee6e-8adf-4461-9a79-1fae6e5a0ddd-image.png

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved