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. Set AutoRepeat for QScrollbar?
Qt 6.11 is out! See what's new in the release blog

Set AutoRepeat for QScrollbar?

Scheduled Pinned Locked Moved General and Desktop
qscrollbar
6 Posts 2 Posters 3.1k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I use a QScrollbar to move within a graphical representation (viewport/canvas kind of thing). I want the user to be able to position the viewport pixel-perfect, therefore I need a singleStep of 1.

    With the default autoRepeat interval of 50 ms, this means a user can only scroll 20 pixels per second that way. There's plenty of CPU power left, so I would like to reduce the interval to 10 or 20 ms.

    How can I do that?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, the keyboard auto-repeat is an OS wide feature that you can't just modify for your application. What you can try to do is take a look at QAbstractButton's documentation to see how they did it and apply it to your scrollbars

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        I was talking about the repeatTime parameter of the protected setRepeatAction parameter. It defaults to 50 ms. It looks like it was intended to be changed, but I can't find the interface for it.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Asperamanca said:

          setRepeatAction

          I completely missed that one ! From what it look, you can play with it from a subclass, so I'd create a subclass of QScrollBar and either change it in the constructor or add a setter to allow to modify it dynamically

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Asperamanca
            wrote on last edited by
            #5

            There's a catch to that: setRepeatAction is used within QScrollbar, but it's not virtual, so I cannot overload it with a different interval (which would be an ugly way to do it, anyway).
            The only way I see that I could really make use of it would be to re-write QScrollbar myself. I was hoping to avoid that.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I did not meant to reimplement setRepeatAction, just use it in a subclass

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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