On Monday 12 March 2007 1:39 pm, V. Armando Sole,
[EMAIL PROTECTED] wrote:
> Hello,
>
> I get a strange error when using QGraphicsView in the way shown below.
>
> The error is:
>
> QObject::startTimer: QTimer can only be used with threads started with
> QThread
>
> What it leaves me perplex is that the error does not appear if the
> getPixmap function is not defined.
> As you may notice, the function is not used at all!
>
> This happens with the most recent sip and PyQt4 snapshots as well as with
> the december snapshots.
> It happens on Qt 4.2.2. and Qt 4.2.3, under linux (tested on 4.2.2) and
> under windows (tested with both).
>
> When building PyQt4 for Qt 4.2.3 on windows with mingw, I had to add myself
> to the path the libqpydesigner.a library found under
> C:\Qt\4.2.3\PyQt-win-gpl-4-snapshot-20070310\qpy\QtDesigner\release. If
> not, PyQt4 was not able to finish the build.
>
> Greetings,
>
> Armando
> Code follows:
>
> import sys
> import PyQt4.Qt as qt
>
> if 1: #if changed to if 0: the error disappears
> def getPixmap():
> mypixmap = None
> return mypixmap
>
> app = qt.QApplication([])
> qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"),
> app,qt.SLOT("quit()"))
> widget = qt.QWidget()
> l = qt.QVBoxLayout(widget)
> scene = qt.QGraphicsScene()
> pixmap = qt.QPixmap()
> pixmapItem = qt.QGraphicsPixmapItem(pixmap, None, scene)
> view = qt.QGraphicsView(scene, widget)
> l.addWidget(view)
> widget.resize(300, 600)
> widget.show()
> sys.exit(app.exec_())
The likely problem is that the objects are being garbage collected (when the
interpreter exits) in an order that Qt doesn't like. When the getPixmap()
function is defined it changes the module dictionary and (by luck only) the
order in which the dictionary contents get collected to something that is Ok
to Qt.
Phil
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt