How to use custom drawing in QGraphicsViews 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:22 UTC
Read the original article
Hit count: 381
I need to view QGraphicsScene in 2 QGraphicsViews with condition that they have different scale factors for items in scene. Closest function which I found is drawItems(), but as far I can understand, it must be called manually. How to repaint views automatically? 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.
© Stack Overflow or respective owner