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);
ui.listWidgetDatabaseDrivers->setItemSelected(ui.listWidgetDatabaseDrivers->findItems(in.readLine(), Qt::MatchExactly)[0], true);
To copy to clipboard, switch view to plain text mode
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
}
if(listWidgetDatabaseDrivers->selectedItems().isEmpty())
{
//Then it's not OK to proceed
}
To copy to clipboard, switch view to plain text mode
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?
Bookmarks