Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How to detect if mouse is holding the scroll bar QPlainTextEdit

    General and Desktop
    2
    3
    2932
    Loading More Posts
    • 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.
    • M
      mirswith last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • D
        dangelog last edited by

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

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply Reply Quote 0
        • M
          mirswith last edited by

          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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post