powlee
5th April 2012, 13:13
Hi,
I have a little bit of trouble with my application crashing while filling a combo box.
gameLabel = new QLabel(tr("Spielname:"));
gameCombo = new QComboBox();
connect(gameCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(loadGameInfo(int)));
QSqlTableModel *games = new QSqlTableModel();
games->setTable("games");
games->setSort(1, Qt::AscendingOrder);
games->select();
qDebug() << "LoadGameDialog: Row Count";
qDebug() << games->rowCount();
for (int i = 0; i < games->rowCount(); ++i) {
QSqlRecord r = games->record(i);
qDebug() << "LoadGameDialog: name ";
qDebug() << r.value("name").toString();
qDebug() << "LoadGameDialog: id_games";
qDebug() << r.value("id_games");
gameCombo->addItem(r.value("name").toString(), r.value("id_games"));
qDebug() << "Item added to combo box";
}
I'm not even sure if the addItem() function is the problem since it worked fine till now. But the commandline output lead me to the conclusion that the crash is caused by the addItem() function.
Here is the Console
Starte E:\Workspace\MASA\trunk\MASA-build-desktop\debug\MASA.exe...
[Main] Cannot load translation file
[DbConnection] DB Connection "qt_sql_default_connection" established
Enter MainWindow::loadGame
before new dialog
LoadGameDialog: Row Count
72
LoadGameDialog: name
"20120207-TestKameraeinstellungUSZ"
LoadGameDialog: id_games
QVariant(int, 73)
E:\Workspace\MASA\trunk\MASA-build-desktop\debug\MASA.exe beendet, Rückgabewert -1073741819
I have a little bit of trouble with my application crashing while filling a combo box.
gameLabel = new QLabel(tr("Spielname:"));
gameCombo = new QComboBox();
connect(gameCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(loadGameInfo(int)));
QSqlTableModel *games = new QSqlTableModel();
games->setTable("games");
games->setSort(1, Qt::AscendingOrder);
games->select();
qDebug() << "LoadGameDialog: Row Count";
qDebug() << games->rowCount();
for (int i = 0; i < games->rowCount(); ++i) {
QSqlRecord r = games->record(i);
qDebug() << "LoadGameDialog: name ";
qDebug() << r.value("name").toString();
qDebug() << "LoadGameDialog: id_games";
qDebug() << r.value("id_games");
gameCombo->addItem(r.value("name").toString(), r.value("id_games"));
qDebug() << "Item added to combo box";
}
I'm not even sure if the addItem() function is the problem since it worked fine till now. But the commandline output lead me to the conclusion that the crash is caused by the addItem() function.
Here is the Console
Starte E:\Workspace\MASA\trunk\MASA-build-desktop\debug\MASA.exe...
[Main] Cannot load translation file
[DbConnection] DB Connection "qt_sql_default_connection" established
Enter MainWindow::loadGame
before new dialog
LoadGameDialog: Row Count
72
LoadGameDialog: name
"20120207-TestKameraeinstellungUSZ"
LoadGameDialog: id_games
QVariant(int, 73)
E:\Workspace\MASA\trunk\MASA-build-desktop\debug\MASA.exe beendet, Rückgabewert -1073741819