PDA

View Full Version : QTableView slow scrolling



Khaine
21st March 2016, 17:37
I have a problem with QTableView. Model which I want to display has about 400k of samples (and it's really not much, it's supposed to work with many millions of samples). It's 27 columns with over 13k rows right now. Unfortunately scrolling is very slow. If someone moves mouse cursor quite dynamically he will have to wait good amount of time until scroll bar actually meets vertical position of cursor again. Where can I search for performance drops? What can I do to make it silky smooth? Or maybe it's qt classes that are slow? Data loads from file in an instant. It just appears immediately. Yet slowdown at scrolling is definitelly visible. If window is smaller, then scrolling is faster. It seems that's directly connected to number of samples currently being displayed on screen (rather not total number of samples inside model).

anda_skoa
21st March 2016, 18:20
First thing you could check is how fast the model is without a view.


Instantiate the model
Ask for its rowCount()
Iterate over all rows

- Ask for the row's columnCount()

- Iterate over the columns


* Ask for each columns data, at least the Qt::DisplayRole



Cheers,
_

Khaine
21st March 2016, 20:27
I did tests and model is not a problem here.




qDebug() << "Iteration test start";
timer.start();
rows = dataSetModel->rowCount();
columns = dataSetModel->columnCount();

for (int i = 0; i<rows; i++){

for (int j = 0; j<columns; j++){

value = dataSetModel->data(dataSetModel->index(i,j));

}

}

qDebug() << "Time elapsed: " << timer.elapsed();



Tests for 30 columns and 14k rows show that iterating all samples takes 55 ms.

Tests for 30 columns and 200k rows give us 735 ms to iterate and copy value of each sample (I ordered it to copy received QVariant to empty QVariant value).

So I would say, that model is pretty fast. Also there is no difference if model has 420k samples or 6kk samples, scroll lag is absolutely the same. So problem is with graphical representation by QTableView.