Cóż, skończyło się na modyfikowaniu niestandardowego modelu tabeli, który zrobiłem, aby używać numpy, a teraz jest szybki.
Zastosowanie tego modelu tabela:
import numpy as np
class PandasModel(QtCore.QAbstractTableModel):
"""
Class to populate a table view with a pandas dataframe
"""
def __init__(self, data, parent=None):
QtCore.QAbstractTableModel.__init__(self, parent)
self._data = np.array(data.values)
self._cols = data.columns
self.r, self.c = np.shape(self._data)
def rowCount(self, parent=None):
return self.r
def columnCount(self, parent=None):
return self.c
def data(self, index, role=QtCore.Qt.DisplayRole):
if index.isValid():
if role == QtCore.Qt.DisplayRole:
return self._data[index.row(),index.column()]
return None
def headerData(self, p_int, orientation, role):
if role == QtCore.Qt.DisplayRole:
if orientation == QtCore.Qt.Horizontal:
return self._cols[p_int]
elif orientation == QtCore.Qt.Vertical:
return p_int
return None
pokazać to, czego próbowałem !!! nie możemy odgadnąć problemu – Ja8zyjits
Czy to nie jest jasne? Ładuję 10k linii w tabeli, a przewijanie trwa wiecznie, jaki kod jest potrzebny, kod do ustawienia modelu w tabeli? W innych językach istnieje możliwość sterowania renderowaniem, ale nie mam pojęcia, jak to zrobić w środowisku QT. –
Podobne pytanie w C++: [Wolne działanie QTableView z tysiącami widocznych komórek] (http://stackoverflow.com/questions/19691577/qtableview-slow-performance- with-1000s-of-visible-cells) – Mel