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. QTableWidget scroll one item down.

QTableWidget scroll one item down.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 10.2k 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.
  • M Offline
    M Offline
    maxmotor
    wrote on last edited by
    #1

    Hello Qt devs!

    I have a QTableWidget which contains several rows (holding simple QStrings with information to the user). I am implementing two buttons, which I would like to have the same functionality as the arrow buttons in the scrollbar. The table should not have focus.

    Can this be done?

    Thank you for your time!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      Sure, just call setValue() on the QTableWidget's verticalScrollBar(). For scrolling by exactly one item you may also want to call setVerticalScrollMode(QAbstractItemView::ScrollPerItem).

      And now I'm not sure if the view smart enough to handle that automatically when scrolling programmatically or you have to scroll by a row's height in pixels...

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxmotor
        wrote on last edited by
        #3

        I get this error when trying to call setValue():

        "invalid use of incomplete type 'struct QScrollBar'"

        So I guess it is not possible?

        wrote: "ui.tableWidget->verticalScrollBar()->setValue(1);"

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          You're forgetting the corresponding #include ...

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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maxmotor
            wrote on last edited by
            #5

            Thank you ;)

            Once again you guys save the day ;)

            Keep up the good work!

            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