[PyQt] Getting stuck in an infinite loop in QGraphicsPixmapItem::boundingRect()

dizou di_zou at yahoo.com
Thu Jul 1 16:46:56 BST 2010


I have a widget with a QTreeView, QGraphicsScene, and a QGraphicsView:

MainWidget.py:
class MainWidget(ControlWidget):
    def __init__(self, parent):
        ControlWidget.__init__(self, parent)
        
        self.tree = TreeArea(self)  #TreeArea inherits QTreeView
        self.display = DisplayScene(self)  #DisplayScene inherits
QGraphicsScene
        self.view = DisplayView(self.display)  #DisplayView inherits
QGraphicsView
        self.view.show()
        
        #code to set up layout
    def Open(self):
        fileName = QFileDialog.getOpenFileName(self, "Open File",
QDir.currentPath(), "(*.xml *.xmf *.xmn)")

The QGraphicsScene contains a bunch of QGraphicsPixmapItems in it. The
QGraphicsView displays them on the screen. When I click a "Open" button, I
enter into the Open() function in my widget. When this happens, I go into an
infinite loop where python will continuously go through each
QGraphicsPixmapItem's boundingRect() function.

Here is my class that inherits QGraphicsPixmapItem:

class DisplayItem(QGraphicsPixmapItem):
    def __init__(self, parent, pixmap=None, graphView=None):
        if pixmap:
            self.HasPixmap = True
        QGraphicsPixmapItem.__init__(self, pixmap)
        
        self.setAcceptHoverEvents(True)
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.setZValue(1)
        self.setOffset(-9, -9)
    def boundingRect(self):
        adjust = 2.0
        return QRectF(-10 - adjust, -10 - adjust, 23 + adjust, 23 + adjust)

So what is going on?
-- 
View this message in context: http://old.nabble.com/Getting-stuck-in-an-infinite-loop-in-QGraphicsPixmapItem%3A%3AboundingRect%28%29-tp29047302p29047302.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list