views:

24

answers:

0

Fragment of program code:

def add_link(Item0Num, Item1Num):
    global Mw, View # Mw - MainWindow
    if Item0Num != Item1Num and not link_exists(Item0Num, Item1Num):
        append( links_to(Item1Num), Item0Num )
        append( links_from(Item0Num), Item1Num )
        LinkGi = TLinkGi()
        Mw.Scene.addItem(LinkGi)
        LinkGi.setZValue(200)
        LinkGi.scale(1 / View.Scale, 1 / View.Scale)
        LinkGi.Item0Num = Item0Num
        LinkGi.Item1Num = Item1Num

class TLinkGi(QGraphicsItem):

    def paint(self, Painter, StyleOptionGraphicsItem, Widget):
        global Mw, View
        Pen = QPen(Qt.black, 1)
        Painter.setPen(Pen)
        X0, Y0 = task_center(self.Item0Num)
        self.setPos(X0, Y0)
        X1, Y1 = task_center(self.Item1Num)
        X, Y = int( (X1 - X0) * View.Scale ), int( (Y1 - Y0) * View.Scale )
        Painter.drawLine(0, 0, X, Y)
        #Mw.Scene.update(0, 0, Plan.Size, Plan.Size) # (1)
        #Mw.gvMain.repaint()                         # (2)

    def boundingRect(self):
        global View
        Rect = QRectF(0, 0, Plan.Size, Plan.Size)
        return Rect

This paints such garbage: http://img697.imageshack.us/img697/5395/qpaintergarbage1.jpg 1

When lines (1) and (2) are uncommented things doesn't become much better: http://img63.imageshack.us/img63/9693/qpaintergarbage0.jpg 2

Please help me to solve this problem.