PDA

View Full Version : [QT4] QListWidget:: setItemSelected misbehaving?



KShots
10th March 2006, 20:42
I've got an interesting problem...

Within my code, I am setting an item as selected in a QListWidget within the constructor of the dialog it is embedded in. I use the following code to do so:
ui.listWidgetDatabaseDrivers->setItemSelected(ui.listWidgetDatabaseDrivers->findItems(in.readLine(), Qt::MatchExactly)[0], true);

What this does, is read a driver name from a file and match it up with something in the list. Visually, it works. The dialog shows up, and the correct item is highlighted. Programmatically, Qt thinks that nothing has been selected.

For example, this code checks what is selected:
if(listWidgetDatabaseDrivers->selectedItems().isEmpty())
{
//Then it's not OK to proceed
}

Until I actually go in and click the driver myself, it's not detected that this has been selected.

Is there something I am missing?

wysota
21st March 2006, 14:58
This may be a bug. There are other situations where selections go out of sync too.

KShots
21st March 2006, 15:07
I was afraid of that. Looks like I'll need to upgrade to 4.1.1 and see if this is still a problem there... if so, I'll fill in a bug report.

I'm currently running on 4.0.1, so for all I know it has already been fixed. I'll just need to re-compile it.