*** GMX Spamverdacht *** [PyQt] Robot example

Andreas Pakulat apaku at gmx.de
Sun May 20 18:05:44 BST 2007


On 20.05.07 18:46:46, Lieven Buts wrote:
> 1) The QVariant system to pass color and image objects
> through the drag-and-drop mechanism. I can convert a QColor
> or QImage object to a QVariant, but I don't see the way
> to do the opposite (NOTES 1 and 3).

IIRC you do it like this:
QImage(yourvariant) 
in Python

> 2) The C++ code uses 
> "if (... || (qgraphicsitem_cast<RobotHead *>(this)) && ..."
> to test if a RobotPart object is an instance of the RobotHead subclass
> or not. I have cobbled some Python together to do the same test
> based on the __class__ attribute (NOTE 5), but it's not very elegant.

instanceof can be used I guess, but I'd need more context to know for
sure, i.e. in which class is this code?

> 3) The animation does not work, and when the program exits, it
> prints the message "QObject::startTimer: QTimer can only be used with
> threads started with QThread". I guess it is necessary to explicitly
> create a QThread in Python, but my attempts so far have not succeeded.

No, QTimer should work in the main thread as well, at least if you
started the QApplication via QApplication._exec()

Andreas

-- 
You may worry about your hair-do today, but tomorrow much peanut butter will
be sold.


More information about the PyQt mailing list