我正在使用QTextEdit
,我以1Hz的速率更新文字(特别是setHTML
)。
最初setHtml
方法很快(只有几毫秒);但运行12个小时后,setHTML
返回需要256毫秒,数据是一个包含5列10行的简单表。
程序运行的时间越长,这种增加就会继续。
有谁知道发生了什么?而且,更重要的是,我该如何让它停止?
基本上我正在做的是:
// get the start time
boost::posix_time::ptime start_time = boost::posix_time::microsec_clock::universal_time();
display->setHtml(text);
boost::posix_time::ptime end_time = boost::posix_time::microsec_clock::universal_time();
boost::posix_time::time_duration time_diff = end_time - start_time;
m_renderTimeDebug = double(time_diff.fractional_seconds() / 1000 );
std::cout << "DRAW TIME; took " << m_renderTimeDebug << " ms " << std::endl;
示例link
答案 0 :(得分:1)
我发现这个问题已在Qt 5.9中得到解决。
我假设这是由Qt家伙发现并修复的。我写过Qt 5.8 QTBUG:61137
的缺陷答案 1 :(得分:0)
可能是内存泄漏。您是否正在分配新内存来保存文本或程序中的其他位置?您可以轻松找到使用例如valgrind,如果您使用的是符合Unix标准的系统或调试器。您是否随着时间的推移处理图像变得越来越大?