[PyQt] QGraphicsScene issue
    Jason H 
    scorp1us at yahoo.com
       
    Sat Aug 11 02:20:47 BST 2007
    
    
  
I started using Qt 4.3.1 and PyQt 4.3. When I added the QGraphicsScene, I got the error:
QObject::startTimer: timers cannot be started from another thread
With out me actually using any timers.
Then I wrote the script below (Change sups.jpg) to another file you have on your system.
Everytime it renders the scene, the 
QObject::startTimer: timers cannot be started from another thread
message appears, and floods the console.
After a few moments of running, python crashes It typically rotates 3 or 4 times before crashing.
I am wondering what I am doing wrong?
TIA!
------------------------
import sys
from PyQt4.Qt import *
class TransformThread(QThread):
        def    __init__(self, item, *args):
                QThread.__init__(self, *args)
                self.item=item
                self.counter=0
                
        def run(self):
                while (1):
                    self.counter+=.1
                    self.item.setTransform(QTransform().rotate(self.counter % 360))
                    QApplication.processEvents()
                    #self.msleep(1)
class MainWindow(QMainWindow):
    def __init__(self, *argv):
            QMainWindow.__init__(self, *argv)        
            self.scene=QGraphicsScene()
            self.gv=QGraphicsView(self.scene)
            self.setCentralWidget(self.gv)
            pixmap=QPixmap('sups.jpg')
            self.items=[QGraphicsPixmapItem(pixmap)]
            self.threads=[]
            for item in self.items:
                self.scene.addItem(item)
                self.threads.append(TransformThread(item))
                self.threads[-1].start()                
if __name__=='__main__':
    a=QApplication(sys.argv)
    w=MainWindow()
    w.show()
    a.exec_()
    
       
____________________________________________________________________________________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
    
    
More information about the PyQt
mailing list