April 2018
Beginner
714 pages
18h 21m
English
Since the scene is already a QObject, adding a property to it was easy. However, imagine that you want to create a game for two players, each controlling a separate Player item. In this case, the jump factors of two elephants need to be animated independently, so you want to make an animated property in the Player class, instead of putting it to the scene.
The QGraphicsItem item and all standard items introduced so far don't inherit QObject and thus can't have slots or emit signals; they don't benefit from the QObject property system either. However, we can make them use QObject! All you have to do is add QObject as a base class and add the Q_OBJECT macro:
class Player : public QObject, ...
Read now
Unlock full access