PDA

View Full Version : Why "setCurrentItem" in a QComboBox doesn't change the text shown?



Dark_Tower
6th April 2006, 00:01
Hi all, I need to use a QComboBox to let the user introduce the path to a directory. I have a button connected to a slot where I call to QFileDIalog::getExistingDirectory. So the user can choose a directory in the file system. When this dialog is closed I check if the path exists in the combo box with QComboBox::findText. If it's not present I call to QComboBox::addITem to add this new path. If it's present I call to QComboBox::setCurrentIndex with the index obtained from "findText". The problem is that it doesn't change the text that is shown in the combo box. Is it the correct behaviour or I am doing something wrong?

Thanks.

munna
6th April 2006, 04:47
Check if your findText(QString &) is returning the correct index or is it returning -1.

Dark_Tower
6th April 2006, 08:21
Check if your findText(QString &) is returning the correct index or is it returning -1.

That was exactly the problem ;) I had to convert the separator of the path with QDir::convertSeparators before check if it exists in the combo :rolleyes: Thanks