开发者

Database view in pyqt

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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜