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?
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?