Qt 模型/视图与标准小部件 [英] Qt model/view vs standard widget

查看:66
本文介绍了Qt 模型/视图与标准小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在阅读 Qt 的模型/视图 教程,但是我仍然不确定是否应该在 Qt 程序中使用模型/视图或小部件:

I am currently reading model/view tutorial from Qt, but I am still not sure if I should use model/view or widget for my Qt program :

我需要做一个记录器应用程序来监控模拟环境中的所有信息.基本场景可能是:

I need to do a logger application that will monitor all information in a simulation environment. Basic scenario might be :

  1. 用户 1虚拟实体 B 说一些话(记录器应用程序获取用户 1 说的话并在表视图或列表视图中显示)
  2. 虚拟实体 B用户 1 回复一些内容(记录器应用程序获取用户 1 所说的话并将其添加到表视图或列表视图中)
  1. User 1 say something to virtual entity B (logger application get what user 1 said and show it in table view or list view)
  2. Virtual entity B reply something to user 1 (logger application get what user 1 said and add it in table view or list view)

此记录器应用程序的需求是实时获取此信息,而且收集的数据不可编辑.本质上,这只是为了显示日志.

The needs of this logger application is to get this information in real time and also, the data collected will NOT be editable. Essentially, this is just to show logs.

那么,对于我想做的事情,使用模态/视图或小部件是否值得?

So, is it worth it to use modal/view or widget is enough for what I want to do?

谢谢

推荐答案

我有模拟目标和模拟问题.我看了这两种解决方案.

I had simular target and simular question. I looked both solutions.

我创建了 20 mb 大小的日志文件.然后,我将他加载到带有自己模型的 QTableView 中,并加载到带有标准模型的 QTableWidget.

I created log file with 20 mb size. Then, I loaded him into QTableView with own model, and to QTableWidget with standard model.

QTableView 比 QTableWidget(约 1.5 分钟)更快(约 30 秒),但 QTableWidget 的解决方案更容易.

QTableView was more faster (about 30 sec) than QTableWidget (about 1.5 min), but solution with QTableWidget was easer.

关于你的问题,我认为,如果你有大日志(许多信息必须立即加载),你应该使用 QTableView 和自己的模型.其他更简单的是使用 QTableWidget 和标准模型.

About you question i think, if you will have big log (many information must be loaded immediately), you should use QTableView with own model. Else more easer is use QTableWidget with standard model.

这篇关于Qt 模型/视图与标准小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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