广告公司网站建设方案,常德做网站专业公司哪家好,网站建设没付尾款,成都 高端网站建设目录
1. 问题的提出
2. 问题解决 1. 问题的提出 今天通过一张像素为141 * 214#xff0c;大小为426KB的svg格式的图片构造QGraphicsSvgItem对象#xff0c;再通过Qt的Graphics View Framework框架#xff0c;将QGraphicsSvgItem对象显示到场景视图上#xff0c;代码如下大小为426KB的svg格式的图片构造QGraphicsSvgItem对象再通过Qt的Graphics View Framework框架将QGraphicsSvgItem对象显示到场景视图上代码如下
#include QElapsedTimer
#include QGraphicsSvgItem
...... // 其它头文件略...... // 其它代码略auto pBatteryChargeGraphicsScene new QGraphicsScene(this);
ui-graphicsView-setScene(pBatteryChargeGraphicsScene);QElapsedTimer timer;
timer.start();auto pPeiDianGuiComponent new QGraphicsSvgItem(QStringLiteral(:/uavGuarantee/image/batteryChargeShelters/peidiangui.svg));qDebug() The slow operation took timer.elapsed() milliseconds;pPeiDianGuiComponent-setPos(100, 100);
pBatteryChargeGraphicsScene-addItem(pPeiDianGuiComponent);...... // 其它代码略其中ui-graphicsView为QGraphicsView类对象第13行竟然耗时6376毫秒如下 最要命的是程序一起来就需要加载QGraphicsSvgItem对象上百个那就更慢了十分影响用户体验。
2. 问题解决
用Adobe Photoshop打开svg图片选择“文件-导出-导出为...”,如下 在右侧“重新采样”下拉框中选择“两次线性”然后单击右下角“导出”按钮此时原来426KB的svg图片变为了10KB然后改为加载此10KB的svg图片效率提升很多耗时如下