Code: Alles auswählen
tabModel = new QSqlTlabeModel(this);
tabModel->setTable("tabExpenses");
tabModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
tabModel->select();
ui.setupUi(this);
ui.comboBox_Country->setFocus();
ui.comboBox_Country->setModel(tabModel);
ui.comboBox_Country->setModelColumn(tabModel->fieldIndex("country"));
Code: Alles auswählen
// Slot "Add New Country":
void FormExpenses::addNewCountry()
{
int row = tabModel->rowCount();
tabModel->insertRows(row, 1);
tabModel->setData(tabModel->index(row, 0), row +1);
tabModel->submit();
mapper->setCurrentIndex(row);
ui.comboBox_Country->setFocus();
reqNewCountry = TRUE;
}
// Slot "Submit Expenses data":
void FormExpenses::submitExpenses()
{
tabModel->submitAll();
tabModel->select();
reqNewCountry = FALSE;
ui.comboBox_Country->update();
}
(Z.B.: es gibt nur zwei Länder: "Deutschland" und "USA". Ich füge ein drittes Land hinzu ("UK"): in der Combobox ist aber "Deutschland", "USA" und wieder "Deutchland" zu sehen...)
Und das obwohl in der Datenbank der richtige Wert steht: den sieht man auch, wenn das Forumular geschlossen und wieder geöffnet wird.
Was zum Geier mache ich falsch?
Gruß
Harry