开发者

Database view in pyqt

开发者 https://www.devze.com 2023-03-24 18:23 出处:网络
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

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

精彩评论

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