I tried using the scrollbar directly and that didn't work either. I added the following after selecting the found item:
QScrollBar* sb
= ui.
listWidget->verticalScrollBar
();
int min = sb->minimum();
int max = sb->maximum();
int range = max - min;
// Take the found row as a fraction of the count
int r = row + 1;
int c = ui.listWidget->count();
int v = (100 * r) / c;
// Move to that fraction of the scrollbar range
int p = (range * v) / 100;
p += min;
sb->setValue(p);
QScrollBar* sb = ui.listWidget->verticalScrollBar();
int min = sb->minimum();
int max = sb->maximum();
int range = max - min;
// Take the found row as a fraction of the count
int r = row + 1;
int c = ui.listWidget->count();
int v = (100 * r) / c;
// Move to that fraction of the scrollbar range
int p = (range * v) / 100;
p += min;
sb->setValue(p);
To copy to clipboard, switch view to plain text mode
Bookmarks