Results 1 to 1 of 1

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

  1. #1
    Join Date
    Sep 2009
    Posts
    60
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

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

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

    MainWidget.py:
    Qt Code:
    1. class MainWidget(ControlWidget):
    2. def __init__(self, parent):
    3. ControlWidget.__init__(self, parent)
    4.  
    5. self.tree = TreeArea(self) #TreeArea inherits QTreeView
    6. self.display = DisplayScene(self) #DisplayScene inherits QGraphicsScene
    7. self.view = DisplayView(self.display) #DisplayView inherits QGraphicsView
    8. self.view.show()
    9.  
    10. #code to set up layout
    11. def Open(self):
    12. fileName = QFileDialog.getOpenFileName(self, "Open File", QDir.currentPath(), "(*.xml *.xmf *.xmn)")
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. class DisplayItem(QGraphicsPixmapItem):
    2. def __init__(self, parent, pixmap=None, graphView=None):
    3. if pixmap:
    4. self.HasPixmap = True
    5. QGraphicsPixmapItem.__init__(self, pixmap)
    6.  
    7. self.setAcceptHoverEvents(True)
    8. self.setFlag(QGraphicsItem.ItemIsMovable)
    9. self.setFlag(QGraphicsItem.ItemIsSelectable)
    10. self.setZValue(1)
    11. self.setOffset(-9, -9)
    12. def boundingRect(self):
    13. adjust = 2.0
    14. return QRectF(-10 - adjust, -10 - adjust, 23 + adjust, 23 + adjust)
    To copy to clipboard, switch view to plain text mode 

    I went through the program with a debugger, and I ended up in the boundingRect() function. I go into the boundingRect() function right as I execute the "fileName = QFileDialog.getOpenFileName" command. Also, if I don't set the pixmaps on the QGraphicsPixmapItems, I don't have this problem. This only happens when the QGraphicsPixmapItems have a pixmap. So what is going on?
    Last edited by di_zou; 2nd July 2010 at 16:07.

Similar Threads

  1. infinite loop
    By zakis in forum Qt Programming
    Replies: 1
    Last Post: 4th November 2009, 17:52
  2. Replies: 4
    Last Post: 19th August 2009, 19:38
  3. Replies: 7
    Last Post: 6th March 2008, 18:24
  4. Infinite loop - resize parent from child
    By bitChanger in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2006, 13:21
  5. is it possible to stay on a user defined infinite loop?
    By mahe2310 in forum Qt Programming
    Replies: 9
    Last Post: 24th March 2006, 14:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.