PDA

View Full Version : Where can I find a list of QPropertyAnimation setProperty values?



technoViking
11th November 2009, 01:11
Hi guys,

I think its strange that I have to go through random posts here and there to try to gather a list of possible values for the QPropertyAnimation's setProperty() function.


Example:
If you want to move a widget using QPropertyAnimation, you need to supply it an argument setProperty("geometry")
if you want to modify the opacity of an item you need to supply it an argument of "opacity"

If you want to change its ycoordinates you need to supply "yaxis"

Where is there a list of all of these? How do these people know what to supply it?

aamer4yu
11th November 2009, 06:04
property is a virtue of QObject. So the list of properties depends on the QObject you have set in QPropertyAnimation.

Am not sure about the "yaxis" since you didnt mention the type of object. it seems to be a value of enum Axis. And I dont know where it is used until you can tell which object you used it on :)

technoViking
11th November 2009, 09:14
Ahh I see...

Well I'm using a widget and I'm putting it in a graphic scene by using a proxy widget.

But what confuses me is I can move the widget using "geometry" and I can set its transparency by modifying "opacity"

but when I look here at all the properties in QGraphicsItem, I don't see "geometry" being a property...but if its not a property how am I moving it? Is it a property of some other class it may have inherited from?

I'm looking here: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qgraphicsitem.html

opacity is there I see.

wysota
11th November 2009, 10:26
You can't animate QGraphicsItem using QPropertyAnimation. It is so simply because QGraphicsItem has no properties. You can animate subclasses of QGraphicsObject like QGraphicsWidget. You can find the list of their properties in their docs - "geometry" is a property of QWidget and QGraphicsWidget. I don't know how this exactly maps to PyQt as properties are not listed there so I guess you may have to rely on C++ docs or wait for PyQt for Qt4.6.

Lykurg
11th November 2009, 12:13
You can't animate QGraphicsItem using QPropertyAnimation. It is so simply because QGraphicsItem has no properties.
But you can add properties with a small "trick":

Animations and the Graphics View Framework

When you want to animate QGraphicsItems, you also use QPropertyAnimation. However, QGraphicsItem does not inherit QObject. A good solution is to subclass the graphics item you wish to animate. This class will then also inherit QObject. This way, QPropertyAnimation can be used for QGraphicsItems. The example below shows how this is done. Another possibility is to inherit QGraphicsWidget, which already is a QObject.


class Pixmap : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
...

As described in the previous section, we need to define properties that we wish to animate.

Note that QObject must be the first class inherited as the meta-object system demands this.

technoViking
11th November 2009, 20:54
Well now i'm confused...

I thought my objects are QGraphicItems? Some other user just told me that because I'm using a ProxyWidget (you need a proxyWidget to add a widget to a graphic scene), he said a ProxyWidget inherits from a QGRaphicsWidget.

Either way I have this widget/graphics item in the scene and QPropertyAnimation is working on it and I didn't mess around with Q_Property.

Is it becuase the proxy widget inherits things from QObject, is that why I can use PropertyAnimation?



38 public functions inherited from QGraphicsWidget
29 public functions inherited from QObject
132 public functions inherited from QGraphicsItem
33 public functions inherited from QGraphicsLayoutItem

wysota
11th November 2009, 23:37
You have already answered your own question by the last quote.

technoViking
12th November 2009, 00:25
Thanks for the responce, so why would you have to use the Q_Property to define the properties yourself if you can simply inherit it from a class? Seems like less work but maybe its for overhead reasons. I'm very new to Qt and I hvan't touched C++ in years so I may be asking dumb questions.

wysota
12th November 2009, 01:51
Thanks for the responce, so why would you have to use the Q_Property to define the properties yourself if you can simply inherit it from a class?
Nobody said you should do that. But QGraphicsItem doesn't inherit any properties. Only QGraphicsWidget and its subclasses do (from QGraphicsObject and its descendants).