I am a bit frustrated with seg faults.

I have the following main
Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. bool connection;
  4.  
  5.  
  6. QApplication app(argc, argv);
  7.  
  8. if (!createConnection())
  9. connection = false;
  10.  
  11. else
  12. connection = true;
  13. qDebug()<<"connection: "<<connection;
  14. mainWindow start(connection,0);
  15. start.show();
  16. return app.exec();
  17. }
To copy to clipboard, switch view to plain text mode 

and the connection.h is

Qt Code:
  1. inline bool createConnection()
  2. {
  3. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
  4. db.setDatabaseName("ppl.db");
  5. if (!db.open()) {
  6. QMessageBox::critical(0,QObject::tr("Non riesco a connettermi al database. Controlla il nome o verifica che il file sia presente"),db.lastError().text());
  7. return false;
  8. }
  9. return true;
  10. }
To copy to clipboard, switch view to plain text mode 

Now, in mainWindow.cpp I have a QTableView tied with a database:

Qt Code:
  1. QSqlQueryModel *model = new QSqlQueryModel(this);
  2. model->setQuery("SELECT * FROM persone");
  3. ...
  4. QTableView *listTable = new QTableView(this);
  5. listTable->setShowGrid(false);
  6. listTable->setModel(model);
  7. ...
  8. connect(listTable,SIGNAL(clicked(const QModelIndex &)),this,SLOT(updateDetails(const QModelIndex &)));
  9. }
  10.  
  11. void mainWindow::updateDetails(const QModelIndex &selection)
  12. {
  13. /* Get the selected indexes in the TableView*/
  14. if (selection.isValid()) {
  15. qDebug() << selection.row();
  16. QSqlRecord rec = model->record(0);
  17.  
  18. // QString temp = record.value("nome").toString();
  19. }
  20.  
  21. }
To copy to clipboard, switch view to plain text mode 
The compilation is good, but when i click on the first row of the Table a seg fault is fired.
Any help?
Attached is an excerpt of the gdb output:

Qt Code:
  1. \#0 QSqlRecord (this=0xbf8a4388, other=@0x16d45a8) at ../../include/QtCore/../../src/corelib/arch/qatomic_i386.h:122
  2. \#1 0x0082d40c in QSqlQueryModel::record (this=0xbf8a54d8, row=0) at models/qsqlquerymodel.cpp:481
  3. \#2 0x0804b726 in mainWindow::updateDetails ()
To copy to clipboard, switch view to plain text mode