Is there an easy way to display the contents of a table from sqlite in pyqt? The only examples I can find are either in C++开发者_JS百科 or have relational tables.
You can use the QSqlTableModel class and pass it to a QTableView. Assuming you have a QSqlDatabase object named db
,
model = QtSql.QSqlTableModel(self, db)
model.setTable("YourTable")
model.select()
tableview = QtGui.QTableView()
tableview.setModel(model)
tableview.show()
精彩评论