且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

QPainter性能如何提高?

更新时间:2022-06-23 00:38:09

你正在绘制一个QImage。不要这样做,请尝试使用QPixmap。

You're painting a QImage. Don't do that, try with a QPixmap instead.

QImage文档 b
$ b

From the QImage documentation:


QImage是为I / O设计和优化的,像素访问和操作,而QPixmap的设计和优化,在屏幕上显示图像。

QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen."

取决于平台,获取QImage数据进入绘画所需的格式和位置,可能会非常昂贵。

Depending on the platform, getting the QImage data into the format and location needed for painting, can be extremely expensive.

PS:没有必要在堆上创建QImages,因为

P.S.: There is no need to create QImages on the heap, as


由于QImage类使用隐式数据共享,QImage对象可以按值传递。

QImage objects can be passed around by value since the QImage class uses implicit data sharing.