QTableView 非常慢(即使只有 3000 行) [英] QTableView is extremely slow (even for only 3000 rows)

查看:157
本文介绍了QTableView 非常慢(即使只有 3000 行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有 3000 行和 8 列的表格.我使用 QTableView.要插入我做的项目:

I have a table with 3000 rows and 8 columns. I use the QTableView. To insert items I do:

QStandardItem* vSItem = new QStandardItem();
vSItem->setText("Blabla");
mModel->setItem(row, column, vSItem);

其中 mModel 是 QStandardItemModel.如果我没有很多行,一切都很好,但是当我试图想象大数据(大约 3000 行),那么它非常慢(在 64 位 Win 7 上为 20 秒(8 核机器,8 GB 内存!!!)).我可以做些什么来提高性能?

where mModel is QStandardItemModel. Everything is fine if I have not to many rows, but when I am trying to visualize big data (about 3000 rows), then it is extremely slow (20 seconds on Win 7 64-bit (8 core machine with 8 GB of RAM!!!)). Is there anything I can do to improve performance?

提前致谢.

推荐答案

很好地调用了对列或行内容的自动调整大小.

Good call on the autoresize on contents for your columns or rows.

我有一个函数,每次客户端连接到我的服务器应用程序时,都会向表中添加一列.随着表中的列数越来越多,插入时间似乎越来越长.

I have a function that added a column to the table each time a client connected to my server application. As the number of columns in the table got large, the insertion time seemed to take longer and longer.

我在做一个 ui->messageLog->resizeRowsToContents();每一次.我将其更改为仅自动调整正在添加的行的大小 ui->messageLog->resizeRowToContents(0);,并且缓慢消失了.

I was doing a ui->messageLog->resizeRowsToContents(); each time. I changed this to only auto resize the row that was being added ui->messageLog->resizeRowToContents(0);, and the slowness went away.

这篇关于QTableView 非常慢(即使只有 3000 行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆