Reputation: 25
How can i show a table with QTableView and WHERE condition ?
...WHERE numero_conta = 123;
self.model = QSqlTableModel()
self.model.setTable('historico')
self.model.select()
self.tab_extrato = QtWidgets.QTableView(self.tab_2)
self.tab_extrato.setObjectName("tab_extrato")
self.tab_extrato.setModel(self.model)
self.tab_extrato.hideColumn(0)
self.verticalLayout_9.addWidget(self.tab_extrato)
Upvotes: 0
Views: 511
Reputation: 244232
If you want to use "WHERE" then you want to filter the information so you must use the setFilter()
method:
self.model = QSqlTableModel()
self.model.setTable('historico')
self.model.setFilter('numero_conta = 123')
self.model.select()
Upvotes: 2