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. Does ScrollPerPixel ever work?
Qt 6.11 is out! See what's new in the release blog

Does ScrollPerPixel ever work?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 8.1k Views 1 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.
  • R Offline
    R Offline
    rushmore
    wrote on last edited by
    #1

    So I have a QTreeWidget derived class that has big item height (200 pixels, for example). And I often have about 100 items in the view. I found even if I set the vertical scroll mode to ScrollPerPixel, it still scrolls too fast (or too "jumpy"). If I understand correctly, shouldn't ScrollPerPixel mean scroll pixel by pixel? I would expect the view scrolls smoothly like a static image. If I clicked on the up/down arrow buttons on the scroll bar, I expect the view to scroll up/down by one pixel. Instead, it scrolls about 180 pixels a time. How is the step size determined? Is there any way to set it to 1? I tried to obtain the vertical scrollbar and set the step size to 1, but it didn't work.

    Any suggestions?

    Thanks,

    RP

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      No, I think you misunderstand what ScrollPerPixel means. It means that scrolling is not snapped to scroll only complete items at a time, but that you can scroll freely, meaning that only a single line of pixels might be drawn of the last or the first item.

      You can adapt the step size if you want.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rushmore
        wrote on last edited by
        #3

        Thanks for the reply. How do I set step size? I tried to put

        verticalScrollBar()->setSingleStep(..);

        in the constructor or in the code where I add items to the view. Neither worked.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          hi redhouse,

          yes that should work .. I just tried something like this and it just works fine.
          @
          verticalScrollBar = new QScrollBar(centralWidget);
          verticalScrollBar->setSingleStep(5);
          @

          or can u paste some test code here that exactly shows the problem

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

            You might have to do that after a layout change, and both the constructor and the item adding is too early for that. You can test that by simply setting it with a timer a second after setting the data or something like that.

            Best solution would be to dig through the sources of QTreeView and see where/when the step size is set, so you can re-set it afterwards, of course.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rushmore
              wrote on last edited by
              #6

              I tried set step size in a single shot timer slot. It worked out great. Thanks for the tip.

              I wish ItemView could have a explicit function to overwrite the auto step size resetting at every layout refresh.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                With that working, you might want to see if you can find a method that you can use for this. The timer was just a trick to see if the idea worked at all :-)

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rushmore
                  wrote on last edited by
                  #8

                  I know, it's not perfect. It might fail if the layout took too long to refresh. But it's not critical so I can live with it. I just don't feel like diving into the Qt source code now:-|

                  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