Using Qt 4.2.1/Linux/Eclipse Europa with CDT and Qt plugins.

My application needs a font selection dialog box that restricts available fonts to fixed pitch, non-symbol fonts. The application only displays with one font but you can change which. So, the font selection dialog has a QListWidget of suitable fonts with the application's current font already selected in the list.

My first cut was a Designer generated QDialog with a QListWidget and other necessary controls. I populated the list by filtering a QFontDatabase in my QDialog constructor. I added a member to set the selected font. Iterated the list for the one with the same family name and:

Qt Code:
  1. ui.fontList->setCurrentRow(row);
  2. ui.fontList->item(row)->setSelected(true);
To copy to clipboard, switch view to plain text mode 

That all works nicely, the item is selected and is visible (scrolled into view) in the QListWidget. I suspect there's a redundancy there though but it's harmless at this point.

I decided to move the font selection from a dedicated dialog to a tab on another configuration dialog. I copied the code and repeated the Designer layout and very carefully verified everything was copied and fixed up properly. This time, the correct item is selected but, it is not scrolled into view unless it was in the top visible items. Just for kicks I added a scrollToBottom() after the above and it had no effect. Remember the correct item is selected so I know execution is passing through this but I single stepped it and confirmed it anyway.

As far as I can tell the only difference is that the QListWidget's parent has gone from being a QDialog to being a QWidget in a QTabWidget.

Thanks for any advice/suggestions.