int id = model->index(index.row(), 1).data().toInt();
The sequence of the columns in the query is the same as in the model and the view so 0=name, 1=id. The model is obtained either directly from the class where you have it or from the view using QListView::model().
Since I tried to use a model and failed, I became curious. I have done one more example using this tutorial, and it went fine. Do you have any idea why is it complaining about my database not being open, when it clearly is, judging from the fact that my query worked fine.
Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.