在Python中通过QGLWidget重绘2D图形

时间:2018-03-06 16:28:33

标签: python qt opengl

def paintEvent(self, event):
    """ Paint scene and selected region"""

    super(self.__class__, self).paintGL()
    #Draw selected region

    if self.selectionMode:
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing, True)
        dxx = self.lastPos.x()-self.lastPosInit.x()
        dyy = self.lastPos.y()- self.lastPosInit.y()
        painter.drawRect(self.lastPosInit.x(), self.lastPosInit.y(), self.pose[0]+dxx, self.pose[1]+dyy)

        # Paint vertexes inside selected volume box
        #for vert in self.meshmodel.point_to_draw:
         #   painter.drawEllipse(vert[0] - 5, vert[1] - 5, 10, 10)
        painter.end()

父类正在绘制OpenGL的东西。当我加载配置文件时,一切都很好:

image

我的问题是在绘制边界框后,网格颜色发生变化:

image2

任何人都可以帮助我吗?

0 个答案:

没有答案