Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to calculate range in QScrollBar?



  • Hi,

    I have QScrollArea and big widget on it ( 1000x2000 ):

    this->setWidget(bigWidget);
    

    so QScrollArea has vertical QScrollBar too. I would like to know how can I calculate range values. When verticalScrollBar is up, the value is 0. I would like to know what is maximum Value ( when the verticallScrollBar will be on down ). When my BigWidget has height = 312, maximum value for verticallScrollBar is 1690.

    1690 + 312 = 2002 != 2000

    So why that 2?


  • Moderators

    @qwe3
    the extra 2 pixel are coming either from the top/bottom border or margin/padding in a layout etc
    check the value returned from frameWidth() of the scrollarea widget


  • Moderators

    @qwe3
    the extra 2 pixel are coming either from the top/bottom border or margin/padding in a layout etc
    check the value returned from frameWidth() of the scrollarea widget


Log in to reply