ITeye博客

QPainter在4K屏上绘制不清楚 (QPainter not clear in high DPI)

johnsmith9th · 2021-12-31 10:23 · Qt · 编程语言 · Markdown

如果是先将内容绘制到一个图片缓存上的话,这个图片缓存需要放大到设备坐标系了,而不是简单的逻辑坐标系大小。参考来源: https://stackoverflow.com/questions/42011410/qt-drawing-high-dpi-qpixmaps。

具体做法如下:

假如代码是这么写的: m_pBufferImg = new QPixmap(this->width(),this->height());QPainter p(*m_pBufferImg);...

则需要改为: qreal dpr = this->devicePixelRatioF();m_pBufferImg = new QPixmap(this->width()*dpr,this->height()*dpr); m_pBufferImg r->setDevicePixelRatio(dpr); QPainter p(*m_pBufferImg);...

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。