i have a QTableView. I am Querying data from database using QtSql.QSqlQuery
.
SQL = 'SELECT * FROM table1'
Query = QtSql.QSqlQuery(database)
Query.prepare(SQL)
Query.exec_()
model = QtSql.QSqlTableModel()
model.setTable('Table')
model.setQuery(Query)
proxy = QtGui.QSortFilterProxyModel()
proxy.setSourceModel(model)
QTableView.setModel(proxy)
Everything is working file the Query result is show in the QTableView
.
My Issues is when i change the SQL
statement which results Query
to return 0 records, I need to clear the data and the cells in the QTableView
I tried using QTableView.clear()
its clearing the data in the cells leaving behind empty rows and columns. How can i clear QTAbleView
completly
My research on clearing data worked.
I Used proxy.deleteLater()
Hope someone could get benefited who comes across the same situation