Hi
I try to create a C++ extension for QML. I have one problem. I have an item (button) that can have set a custom gradient:

(I've pasted only important (in my opinion) code)

Qt Code:
  1. class Button : public QDeclarativeItem {
  2. Q_OBJECT
  3. Q_PROPERTY(Gradient* gradient READ gradient WRITE setGradient)
  4.  
  5. public:
  6. Gradient* gradient() const;
  7. void setGradient(Gradient* gradient);
  8. };
To copy to clipboard, switch view to plain text mode 

QML file:

Qt Code:
  1. Button {
  2. ExtendedGradient {
  3. ExtendedGradientStop { position: "0, 0"; color: "red"; }
  4. ExtendedGradientStop { position: "120, 120"; color: "blue"; }
  5. }
To copy to clipboard, switch view to plain text mode 

and ExtendedGradient / ExtendedGradientStop classes:

Qt Code:
  1. class Gradient : public QObject
  2. {
  3. Q_OBJECT
  4.  
  5. Q_PROPERTY(QDeclarativeListProperty<GradientStop> stops READ stops)
  6. Q_CLASSINFO("DefaultProperty", "stops")
  7.  
  8. public:
  9. Gradient(QObject *parent=0);
  10. virtual ~Gradient();
  11.  
  12. QDeclarativeListProperty<GradientStop> stops();
  13. QGradient* gradient();
  14.  
  15. private:
  16. QList<GradientStop *> stops_;
  17. QGradient *gradient_;
  18.  
  19. friend class GradientStop;
  20. };
  21.  
  22. class GradientStop : public QObject
  23. {
  24. Q_OBJECT
  25.  
  26. // properties and set/get methods
  27. };
  28.  
  29. QML_DECLARE_TYPE(Gradient)
  30. QML_DECLARE_TYPE(GradientStop)
To copy to clipboard, switch view to plain text mode 

Problem is that: In qml file I set a ExtendedGradient, but setter for this property is never called. Instead of this, it is set the dynamic property which have a name 'gradient' (the Gradient* Button::gradient_ is always 0x0).
This property isValid, !isNull, has correct typeName, but I cannot convert it to Gradient* (using property("gradient").value<Gradient*>()) - I always get 0x0.

Why the setGradient setter is not called? Is this possible to force a call of this method? What I'm doing wrong?