P
P
pypyshka2017-01-11 11:44:41
Python
pypyshka, 2017-01-11 11:44:41

How to remove the limit on the number of displayed records in the tableView?

Good afternoon.
I am using Python 3.4.4 and PyQt 4.11.4. In the program, you need to display data from the SQLite database into a table. I drew a tableView and display all the records there:

db_connect = QtSql.QSqlDatabase.addDatabase("QSQLITE")
db_connect.setDatabaseName("datebase.db")
db_connect.open()
model = QtSql.QSqlQueryModel(parent = main_window)
model.setQuery("SELECT * FROM table")
model.setHeaderData(1, QtCore.Qt.Horizontal, "Дата")
model.setHeaderData(2, QtCore.Qt.Horizontal, "Тип")
model.setHeaderData(3, QtCore.Qt.Horizontal, "Номер")
main_window.tableView.setModel(model)
main_window.tableView.setColumnHidden(0, True)
main_window.tableView.resizeColumnsToContents()
main_window.tableView.horizontalHeader().setStretchLastSection(True)
db_connect.close()

Everything was fine, but I ran into a problem: all records in the database after 257 are not displayed in the tableView. If you delete some of the first entries, then some new ones will be loaded. Can you please tell me how to bypass this limitation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pypyshka, 2017-01-23
@pypyshka

Problem solved like this:

while model.canFetchMore():
    model.fetchMore()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question