How to detect if mouse is holding the scroll bar QPlainTextEdit



  • Is there a way to detect if the mouse is holding onto a scroll bar within the QPlainTextEdit control? I am using QPlainTextEdit as a log viewer and while messages are being spit out I keep the view scrolled to keep the new text in view, this is working great however I would like to let the user override this auto scrolling if they are hanging onto the scroll bar.

    I have tried subclassing QPlainTextEdit and overridding the mousePress/ReleaseEvent's however these never get called and I do not see any obvious signals that would help notify me when the user has grabbed/released the scroll bar.

    Any ideas?

    Thanks.



  • Don't scroll down automatically unless the view is already scrolled down?



  • That's a great idea and is working wonderfully.

    I opted for this approach in the end, however I did manage to get it working the other way as well, silly me did not notice the isSliderDown() call for QScrollBar's. One caveat to your approach is that I had to set a flag to determine if this was the first time I am appending text in which case I move the scroll bar to the maximum position.

    Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.