QTableWidget scroll one item down.



  • 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!



  • 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...



  • 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);"



  • You're forgetting the corresponding #include ...



  • Thank you ;)

    Once again you guys save the day ;)

    Keep up the good work!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.