I have 2 classes, one MainWindow in which we draw in a QGraphicsView a circle (which intend to become a button !) created thanks to an other class. The class MyCircle inherits from QObject and QGraphicsItem since I want to make animation.
My issue is the following :
My goal is first to make a simple animation on my drawing : make it smaller then it goes back to the original size. So I suppose I should use the property geometry, already existing in the QObject class.
To do this I write in my MainWindow.ccp
animationBoutonRondTaille = new QPropertyAnimation(roundButton, "geometry");
animationBoutonRondTaille->setDuration(1000);
animationBoutonRondTaille->setKeyValueAt(0, QRect(-100, -100, 200, 200));
animationBoutonRondTaille->setKeyValueAt(0.5, QRect(-80,-80,160,160));
animationBoutonRondTaille->setKeyValueAt(1, QRect(-100, -100, 200, 200));
animationBoutonRondTaille -> start();
If I don't include
class MyCircle : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
/.../
}
I got the following error message :
QPropertyAnimation: you're trying to animate a non-existing property geometry of your QObject
But if I do, i got this one :
'class MyCircle' has no member named 'geometry'/'setgeometry'
What is the purpose of inheriting QObject if I have to define all by myself the geometry property ?
Hope you can help me, and sorry if my question is vague, it's the first for me so I don't really know what you expect.
Thanks a lot if you take time to answer.