Hello,
I'm implementing my "QCombobox set current data" and I’m in doubt about what is the better way?
1) using variable and QMapIterarot to manipulate data, and QCombobox.setCurrentText()
QMapIterator<QString, int> i(_cbNames);
while (i.hasNext()) {
i.next();
if (query2.value(1) == i.key())
{
ui->qcomboboxNames->setCurrentText(i.key());
}
QMapIterator<QString, int> i(_cbNames);
while (i.hasNext()) {
i.next();
if (query2.value(1) == i.key())
{
ui->qcomboboxNames->setCurrentText(i.key());
}
To copy to clipboard, switch view to plain text mode
2) using directly combobox to manipulate data and QCombobox.setCurrentIndex()
for (int i=0;i<=ui->qcomboboxNames->count();i++)
{
ui->qcomboboxNames->setCurrentIndex(i);
if (query2.value(1) == ui->qcomboboxNames->currentText())
{
break;
}
}
for (int i=0;i<=ui->qcomboboxNames->count();i++)
{
ui->qcomboboxNames->setCurrentIndex(i);
if (query2.value(1) == ui->qcomboboxNames->currentText())
{
break;
}
}
To copy to clipboard, switch view to plain text mode
Thanks!
Juliano
Bookmarks