Now I created 2 QComboBOxes like this:
QString town, town_number;
//, combined; QSqlQuery query
("SELECT ime,postna_st FROM kraj");
while(query.next()) {
//value 0 corresponds to ime in SELECT statement
town = query.value(0).toString();
town_number = query.value(1).toString();
//combined = town + " " + town_number;
comb.append(town);
comb_number.append(town_number);
}
//sort the list of items in ascending order (case-sensitively)
comb.sort();
comb_number.sort();
//QMap<QString,QString> comb;
kraj_combo->insertItems(0,comb);
kraj_combo_number->insertItems(0,comb_number);
QStringList comb,comb_number;
QString town, town_number;//, combined;
QSqlQuery query("SELECT ime,postna_st FROM kraj");
while(query.next()) {
//value 0 corresponds to ime in SELECT statement
town = query.value(0).toString();
town_number = query.value(1).toString();
//combined = town + " " + town_number;
comb.append(town);
comb_number.append(town_number);
}
//sort the list of items in ascending order (case-sensitively)
comb.sort();
comb_number.sort();
//QMap<QString,QString> comb;
kraj_combo->insertItems(0,comb);
kraj_combo_number->insertItems(0,comb_number);
To copy to clipboard, switch view to plain text mode
but, I what I want to do is this: when one of the items is selected (in either of the QComboBoxes) I want to adjust the second one to the same value (based on the ID number) in the table.
So for example there is an entry like this in table:
London 1000
when I choose 1000, I want the other QComboBox to set itself to London and the other way around. Any idea how to do that?
Bookmarks