[PyQt] QGraphicsScene issue

Hernán Rajchert hrajchert at gmail.com
Sat Aug 11 02:46:47 BST 2007


I had the same problem but not related to the version.
The problem started when i changed
from PyQt4 import QtGui
to
from PyQt4.QtGui import *

So for cleaning the code clean and avoiding the timer issue try:
from PyQt4 import QtGui as G, QtCore as C

and then use G.MainWindow etc...

On 8/10/07, Jason H <scorp1us at yahoo.com> wrote:
>
> 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/
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20070811/6b5668b2/attachment-0001.html


More information about the PyQt mailing list