Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to detect if mouse is holding the scroll bar QPlainTextEdit
QtWS25 Last Chance

How to detect if mouse is holding the scroll bar QPlainTextEdit

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.1k Views
  • 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 Offline
    M Offline
    mirswith
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      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
      0
      • M Offline
        M Offline
        mirswith
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved