how to use drawItems() in PyQt?

Posted by DSblizzard on Stack Overflow See other posts from Stack Overflow or by DSblizzard
Published on 2010-06-06T03:59:56Z Indexed on 2010/06/06 4:02 UTC
Read the original article Hit count: 389

Filed under:
|

I have these two code fragments in program:

class TGraphicsView(QGraphicsView):

    def __init__(self, parent = None):
        print("__init__")
        QGraphicsView.__init__(self, parent)

    def drawItems(self, Painter, ItemCount, Items, StyleOptions):
        print("drawItems")
        Brush = QBrush(Qt.red, Qt.SolidPattern)
        Painter.setBrush(Brush)
        Painter.drawEllipse(0, 0, 100, 100)

...

    Mw.gvNavigation = TGraphicsView(Mw) # Mw - main window
    Mw.gvNavigation.setGeometry(0, 0, Size1, Size1)
    Mw.gvNavigation.setScene(Mw.Scene)
    Mw.gvNavigation.setSceneRect(0, 0, Size2, Size2)
    Mw.gvNavigation.show()

_init_ works, Mw.gvNavigation is displayed and there are Mw.Scene items in it, but drawItems() isn't called. Please explain, what I'm doing wrong.

© Stack Overflow or respective owner

Related posts about pyqt

Related posts about pyqt4