[PyQt] PyQt snapshot crash on Qt5.4 with bogus QGraphicsVideoItem instance

lloyd konneker bootch at nc.rr.com
Fri Jan 2 14:28:13 GMT 2015

This is just a follow up to more clearly document the problem and solution (since I garbled the thread.)

If you are using QGraphicsItems and PyQt and you experience symptoms where an object is mysteriously of type QGraphicsVideoItem (and you are NOT using QGraphicsVideoItem):

The solution is in the file PyQt…/sip/QMultimediaWidgets/qgraphicsvideoitem.sip, delete the code between “%ConvertToSubClassCode” and “%End”, and then totally rebuild PyQt (starting with the configure step.)   It is not enough to just re make, since the configure step is when code is generated using the .sip files.

My understanding of the situation:  QGraphicsItems are lightweight objects not inheriting QObject and thus having no introspection.  For certain calls to Qt that return QGraphicsItem objects (or containers of same) PyQt wraps  the returned objects but must determine their type (subclass of QGraphicsItem) by calling their type() method.  However, QGraphicsVideoItem fails to implement the type() method (which probably should be reported as a bug in Qt).  So PyQt ‘casts’ the objects to QGraphicsVideoItem (unless you follow the solution.)

More information about the PyQt mailing list