[Kde-bindings] Animating custom properties in Qyoto (Q_PROPERTY)
Lorenz Cuno Klopfenstein
lck at klopfenstein.net
Wed Aug 11 08:32:09 UTC 2010
Hello all,
I'm back with another question about the Qyoto/C# bindings to Qt.
I've started using the QPropertyAnimation system of Qt 4.6, which
works really well with Qyoto. However, I've yet been unable to figure
out how to declare a custom property on an object and then animate it.
For instance, animating an existing QWidget property works perfectly
fine:
var pb = new QPushButton("Hello", parent);
var anim = new QPropertyAnimation(pb, "geometry");
anim.Duration = 3000;
anim.StartValue = new QRect(0, 0, 0, 0);
anim.EndValue = new QRect(0, 0, 400, 400);
anim.Start(QAbstractAnimation.DeletionPolicy.DeleteWhenStopped);
However, if I try to declare a custom property on a class deriving
from QObject (or QWidget):
class MyObject : QObject {
int _prop = 100;
[Q_PROPERTY("int", "animProp")]
public int AnimProp {
get { return _prop; }
set {
_prop = value;
Console.WriteLine("Prop {0}", value);
}
}
}
attempting to animate the custom property like this:
var obj = new MyObject();
var anim = new QPropertyAnimation(obj, "animProp");
anim.Duration = 2000;
anim.StartValue = 0;
anim.EndValue = 1000;
anim.Start(QAbstractAnimation.DeletionPolicy.DeleteWhenStopped);
always results in a crash.
The crash stacktrace is as follows:
Unhandled exception: System.Reflection.AmbiguousMatchException:
Ambiguous matching in method resolution
at System.Reflection.Binder.FindMostDerivedMatch
(System.Reflection.MethodBase[] match) [0x00000]
at System.MonoType.GetMethodImpl (System.String name, BindingFlags
bindingAttr, System.Reflection.Binder binder, CallingConventions
callConvention, System.Type[] types,
System.Reflection.ParameterModifier[] modifiers) [0x00000]
at System.Type.GetMethod (System.String name, BindingFlags
bindingAttr) [0x00000]
at Qyoto.SmokeMarshallers.GetProperty (IntPtr obj, System.String
propertyName) [0x00000]
at (wrapper native-to-managed) Qyoto.SmokeMarshallers:GetProperty
(intptr,intptr)
at (wrapper managed-to-native)
Qyoto.SmokeInvocation:CallSmokeMethod (intptr,int,intptr,intptr,int)
at Qyoto.SmokeInvocation.Invoke (System.String mungedName,
System.String signature, System.Type returnType, System.Object[] args)
[0x00000]
at Qyoto.QPropertyAnimation..ctor (Qyoto.QObject target,
Qyoto.QByteArray propertyName) [0x00000]
at TestQyotoAnim.MainClass.Main (System.String[] args) [0x00000]
It appears Qyoto is unable to resolve the correct property accessor to
use. I'm guessing the way I use the Q_PROPERTY attribute is somehow
wrong, but it appears to be similar to what I found in the rest of the
Qyoto source code.
Thank you for your time.
Regards,
--
Lorenz Cuno Klopfenstein
lck at klopfenstein.net
http://lorenz.klopfenstein.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Main.cs
Type: text/x-csharp
Size: 1092 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20100811/7df27caa/attachment.bin>
More information about the Kde-bindings
mailing list