QPicture and Qpainter PyQt4

luca72 lucaberto at libero.it
Mon Sep 17 09:29:43 CEST 2007


Hello at all
I have made this small tests:

this is the form implementation:

# -*- coding: utf-8 -*-

"""
Module implementing Form.
"""

from PyQt4.QtGui import QWidget
from PyQt4.QtCore import pyqtSignature
from PyQt4 import *
from disegni import PictureFrame

from Ui_form import Ui_Form

class Form(QWidget, Ui_Form):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):
        """
        Constructor
        """
        QWidget.__init__(self, parent)
        self.setupUi(self)

    @pyqtSignature("")
    def on_pushButton_clicked(self):
        """
        Slot documentation goes here.
        """
        # TODO: not implemented yet
        #raise "Not implemented yet"
        #gr = QtGui.QPainter()
        picture = QtGui.QPicture()
        gr = QtGui.QPainter()
        gr.begin(picture)
        gr.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.SolidLine))
        gr.drawLine(70,100,150,100)
        gr.end()
        picture.save('dis.pic')
        self.frame.update()

and this is the clas that implements the paint event:

from PyQt4.QtGui import QWidget
from PyQt4.QtCore import pyqtSignature
from PyQt4 import *

class PictureFrame(QtGui.QFrame):

  def __init__(self, parent = None):
    QFrame.__init__(self, parent)
    picture = QtGui.QPicture()

  def paintEvent(self, event):
    picture.load('dis.pic')
    gr = QtGui.QPainter()
    gr.begin(self.frame)
    gr.drawPicture(0, 0, picture)
    gr.end()

But nothing is paint.
Can you give me some help

Regards

Luca




More information about the Python-list mailing list