Search code examples
c++qtqlistwidget

How to scroll QListWidget?


I select some item in QListWidget when it's creating using listWidget->item(sel)->setSelected(true)

But visible area of QListWidget is in the beginning even if the selected item is below fit items.

enter image description here

How can I fix it?


Solution

  • To move the scrollbar to make a specific item visible, use scrollToItem:

    listWidget->scrollToItem(listWidget->item(sel));