I populate a QListView with QSqlTableModel.
projectModel = QSqlTableModel()
projectModel.setTable("project")
projectModel.select()
projectView = QListView()
projectView.setModel(projectModel)
projectView.setModelColumn(1)
- edit my wording a bit. –
Say my QSqlTableModel has 3 columns. (0) for id, (1) for name, (2) for color, for example.
In my QListView I’m displaying column 1, so only the names. Then I have 1 item selected. How can I retrieve that item’s id and color?
Sorry I’m a very beginner at this. Too beginner I can’t figure things out reading documentations 🙁
Though i didn’t fully understand what you are trying to do, I’m showing you the answer of your two question.
For example we have an sqlite3 database “sqlitedb.rdb”
And a table name “info”,
and have some data,
Now,
To do this you can,
You can set which field/column you want to show using the query.
and,
You can navigate through the result of the query and have the data, example,
you can loop through the query and get access to the data.