1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Scroll to the bottom when adding an element to a QScrollArea

Discussão em 'Python' iniciado por Stack, Julho 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a QScrollArea and I would like when a I push my "Add" button that adds Widgets to the widgets contained in the QScrollArea for the scroll to scroll all the way to the bottom

    I made several attempts to Scroll to the bottomw ith code like

    scrollWidget.update()
    bar = scrollWidget.verticalScrollBar()
    bar.setValue(bar.maximum())


    or even using ensureWidgetVisible But what appears to be happening is it scrolls to the bottom of the scroll "Before" the resize occurs, then it resizes so I am not quite at the bottom.

    I verfied this by writing code that checks the bar size, and the maximum bar size and the child count This shows there are new children but the bar size has not yet been updated.

    I then tried to give Qt time to "recaluclate" sizes first by calling:

    QApplication.processEvents()
    scrollWidget.update()


    I do not want the scroll area to ALWAYS be on the bottom but only after pushing my button

    Continue reading...

Compartilhe esta Página