Skip to content

书中案例8-3(双缓存绘图)代码疑似有误,QPixmap应该用深拷贝吧? #12

@GuoShaozheng

Description

@GuoShaozheng

书中案例8-3(双缓存绘图)代码看意图是否以下此处需改为 深拷贝:

PyQt5/Chapter08/qt08_winDraw03.py

目前为:
# 将以前pix中的内容复制到tempPix中,保证以前的内容不消失
self.tempPix = self.pix

是否应改为 :
# 将以前pix中的内容复制到tempPix中,保证以前的内容不消失
self.tempPix = self.pix.copy(self.pix.rect())

否则按目前的形式感觉导致 tempPix 和 pix 引用(操作)的其实是同一块内存。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions