This is my workaround:

Qt Code:
  1. void listTab::changeTo(QString& it)
  2. {
  3. bool funkysb;
  4. int min;
  5. int max;
  6. int range;
  7. int row;
  8. int r;
  9. int c = ui.listWidget->count();
  10. int v;
  11. QString number;
  12.  
  13. sb = ui.listWidget->verticalScrollBar();
  14. min = sb->minimum();
  15. max = sb->maximum();
  16. range = max - min;
  17.  
  18. funkysb = ((range == 0) && (c != 0));
  19. if (funkysb)
  20. {
  21. // The scrollbar range is zero and the control contains
  22. // items, set the scroll range to something useful
  23. min = 0;
  24. max = c - 1;
  25. range = max - min;
  26. sb->setRange(min, max);
  27. }
  28.  
  29. // Find the specified number in the list
  30. for (row = 0; row < c; row++)
  31. {
  32. number = ui.listWidget->item(row)->text();
  33.  
  34. if (number == it)
  35. {
  36. // Make it the current selection
  37. // This resets the scrollbar range to 0,0 if the
  38. // list is in a tab widget with a layout
  39. ui.listWidget->setCurrentRow(row);
  40. ui.listWidget->item(row)->setSelected(true);
  41.  
  42. // Reset the scrollbar range if we have funkiness
  43. r = sb->maximum() - sb->minimum();
  44. if (funkysb && (r != range))
  45. {
  46. sb->setRange(min, max);
  47.  
  48. // Scroll to the item
  49. sb = ui.listWidget->verticalScrollBar();
  50. r = (row + 1) * range;
  51. c = ui.listWidget->count();
  52. v = r / c;
  53. if (r % c)
  54. {
  55. v++;
  56. }
  57. sb->setValue(v);
  58. }
  59. break;
  60. }
  61. }
  62. }
To copy to clipboard, switch view to plain text mode