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

Monitor QScrollArea's Bar Changes



  • hi,

    how to monitor QScrollBarVertical Bar changes ?

    regards



  • Connect to the relevant signal?
    You can get access to the scrollbars using QScrollArea::verticalScrollBar() and horizontalScrollBar().



  • have you tried to look in the docs?
    There are signals for each value change.



  • thx 4 answers
    and srry 4 asking w/o deep search

    i wsolved with
    @
    QAbstractSlider *VBar= (QAbstractSlider *)scrollArea->verticalScrollBar();
    connect(VBar,SIGNAL(sliderReleased()),this, SLOT(Func()));
    @



  • You must not cast to QAbstractSlider pointer type. A QScrollBar inherits from QAbstractSlider, so you can safely assign directly:

    @
    QAbstractSlider *VBar= scrollArea->verticalScrollBar();
    @

    And you're better off to assign it to a QScrollBar pointer, to have access to the other methods too, if necessary. And yes, you do have access to QAbstractSlider's methods and signals too.


Log in to reply