qt自带的网络请求会导致cpu升高吗

44 条评论分享收藏感谢收起请教嵌入式 Qt 框架 QGraphicsView 刷新非常耗 CPU 的问题_百度知道
请教嵌入式 Qt 框架 QGraphicsView 刷新非常耗 CPU 的问题
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
可以使用setSceneRect()设置QGraphicsScene的大小。如果不设置,则默认为scene中包含所有子元素的边界区域( itemsBoundingRect()函数的返回值)。更详细的说明参看QGraphicsScene的文档,讲解很详细,看下面这段:The scene's bounding rect is set by calling setSceneRect()。Items can be placed at any position on the scene, and the size of the scene is by default unlimited. The scene rect is used only for internal bo好keeping, maintaining the scene's item index. If the scene rect is unset, QGraphicsScene will use the bounding area of all items, as returned by itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a relatively time consuming function, as it operates by collecting positional information for every item on the scene. Because of this, you should always set the scene rect when operating on large scenes.
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Qt的Label-&setPixmap();CPU占用太高
[问题点数:40分,结帖人dell_tx]
本版专家分:1429
结帖率 83.33%
CSDN今日推荐
本版专家分:1202
本版专家分:1429
本版专家分:5
本版专家分:11429
匿名用户不能发表回复!
其他相关推荐#include "resource_minitor.h"
#include "sys/statfs.h"
resource_minitor::resource_minitor(QObject *parent) : QObject(parent)
connect(&monitor_timer__, &QTimer::timeout, this, &resource_minitor::get_resource__);
monitor_timer__.start(m_timer_interval__);
void resource_minitor::get_resource__()
get_cpu_usage__ ();
get_disk_speed__();
get_mem_usage__ ();
get_net_usage__ ();
get_disk_space__();
get_path_space("/");
qDebug()&&"\n";
bool resource_minitor::get_mem_usage__()
process.start("free -m"); //使用free完成获取
process.waitForFinished();
process.readLine();
QString str = process.readLine();
str.replace("\n","");
str.replace(QRegExp("( ){1,}")," ");//将连续空格替换为单个空格 用于分割
auto lst = str.split(" ");
if(lst.size() & 6)
qDebug("mem total:%.0lfMB free:%.0lfMB",lst[1].toDouble(),lst[6].toDouble());
return true;
return false;
bool resource_minitor::get_net_usage__()
process.start("cat /proc/net/dev"); //读取文件/proc/net/dev获取网络收发包数量,再除取样时间得到网络速度
process.waitForFinished();
process.readLine();
process.readLine();
while(!process.atEnd())
QString str = process.readLine();
str.replace("\n","");
str.replace(QRegExp("( ){1,}")," ");
auto lst = str.split(" ");
if(lst.size() & 9 && lst[0] == "enp2s0:")
double recv = 0;
double send = 0;
if(lst.size() & 1)
recv = lst[1].toDouble();
if(lst.size() & 9)
send = lst[9].toDouble();
qDebug("%s 接收速度:%.0lfbyte/s 发送速度:%.0lfbyte/s",lst[0].toStdString().c_str(),(recv - m_recv_bytes__) / (m_timer_interval__ / 1000.0),(send - m_send_bytes__) / (m_timer_interval__ / 1000.0));
m_recv_bytes__ =
m_send_bytes__ =
return true;
bool resource_minitor::get_cpu_usage__()
process.start("cat /proc/stat");
process.waitForFinished();
QString str = process.readLine();
str.replace("\n","");
str.replace(QRegExp("( ){1,}")," ");
auto lst = str.split(" ");
if(lst.size() & 3)
double use = lst[1].toDouble() + lst[2].toDouble() + lst[3].toDouble();
double total = 0;
for(int i = 1;i & lst.size();++i)
total += lst[i].toDouble();
if(total - m_cpu_total__ & 0)
qDebug("cpu rate:%.2lf%%",(use - m_cpu_use__) / (total - m_cpu_total__) * 100.0);
m_cpu_total__ =
m_cpu_use__ =
return true;
return false;
bool resource_minitor::get_disk_speed__()
process.start("iostat -k -d");
process.waitForFinished();
process.readLine();
process.readLine();
process.readLine();
QString str = process.readLine();
str.replace("\n","");
str.replace(QRegExp("( ){1,}")," ");
auto lst = str.split(" ");
if(lst.size() & 5)
qDebug("disk read:%.0lfkb/s disk write:%.0lfkb/s",(lst[4].toDouble() - m_disk_read__ ) / (m_timer_interval__ / 1000.0),(lst[5].toDouble() - m_disk_write__) / (m_timer_interval__ / 1000.0));
m_disk_read__ = lst[4].toDouble();
m_disk_write__ = lst[5].toDouble();
return true;
return false;
bool resource_minitor::get_disk_space__()
process.start("df -k");
process.waitForFinished();
process.readLine();
while(!process.atEnd())
QString str = process.readLine();
if(str.startsWith("/dev/sda"))
str.replace("\n","");
str.replace(QRegExp("( ){1,}")," ");
auto lst = str.split(" ");
if(lst.size() & 5)
qDebug("挂载点:%s 已用:%.0lfMB 可用:%.0lfMB",lst[5].toStdString().c_str(),lst[2].toDouble()/1024.0,lst[3].toDouble()/1024.0);
return true;
bool resource_minitor::get_path_space(const QString & path)
struct statfs diskI
statfs(path.toUtf8().data(), &diskInfo);
qDebug("%s 总大小:%.0lfMB 可用大小:%.0lfMB",path.toStdString().c_str(),(diskInfo.f_blocks * diskInfo.f_bsize)/1024.0/1024.0,(diskInfo.f_bavail * diskInfo.f_bsize)/1024.0/1024.0);
return true;求大神指点 qt运行问题 而且电脑很cpu占用率很高
[问题点数:40分,结帖人cainiao_c]
本版专家分:0
结帖率 100%
CSDN今日推荐
本版专家分:4072
本版专家分:58310
2012年6月 移动平台大版内专家分月排行榜第一2012年5月 移动平台大版内专家分月排行榜第一2012年4月 移动平台大版内专家分月排行榜第一2012年3月 移动平台大版内专家分月排行榜第一2012年2月 移动平台大版内专家分月排行榜第一2012年1月 移动平台大版内专家分月排行榜第一2011年12月 移动平台大版内专家分月排行榜第一2011年11月 移动平台大版内专家分月排行榜第一2011年10月 移动平台大版内专家分月排行榜第一2011年9月 移动平台大版内专家分月排行榜第一2011年6月 移动平台大版内专家分月排行榜第一2011年5月 移动平台大版内专家分月排行榜第一2011年4月 移动平台大版内专家分月排行榜第一
2011年8月 移动平台大版内专家分月排行榜第二2011年7月 移动平台大版内专家分月排行榜第二2011年3月 移动平台大版内专家分月排行榜第二
2012年8月 移动平台大版内专家分月排行榜第三2012年7月 移动平台大版内专家分月排行榜第三
本版专家分:58310
2012年6月 移动平台大版内专家分月排行榜第一2012年5月 移动平台大版内专家分月排行榜第一2012年4月 移动平台大版内专家分月排行榜第一2012年3月 移动平台大版内专家分月排行榜第一2012年2月 移动平台大版内专家分月排行榜第一2012年1月 移动平台大版内专家分月排行榜第一2011年12月 移动平台大版内专家分月排行榜第一2011年11月 移动平台大版内专家分月排行榜第一2011年10月 移动平台大版内专家分月排行榜第一2011年9月 移动平台大版内专家分月排行榜第一2011年6月 移动平台大版内专家分月排行榜第一2011年5月 移动平台大版内专家分月排行榜第一2011年4月 移动平台大版内专家分月排行榜第一
2011年8月 移动平台大版内专家分月排行榜第二2011年7月 移动平台大版内专家分月排行榜第二2011年3月 移动平台大版内专家分月排行榜第二
2012年8月 移动平台大版内专家分月排行榜第三2012年7月 移动平台大版内专家分月排行榜第三
本版专家分:22505
2013年10月 荣获微软MVP称号
2013年1月 移动平台大版内专家分月排行榜第二2012年12月 移动平台大版内专家分月排行榜第二
2014年1月 移动开发大版内专家分月排行榜第三2013年4月 移动平台大版内专家分月排行榜第三2013年3月 移动平台大版内专家分月排行榜第三2012年6月 移动平台大版内专家分月排行榜第三
本版专家分:455
本版专家分:4015
本版专家分:4072
匿名用户不能发表回复!
其他相关推荐}

我要回帖

更多关于 qt开发的程序cpu使用率 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信