[Qt-qml] Trivial issue I'm sure

mathias.malmqvist at nokia.com mathias.malmqvist at nokia.com
Thu Feb 3 19:50:55 CET 2011


Hi, 

I've implemented an as-simple-as-you-can-imagine Margins QML type for the 
Qt Components implementation. 

Defining a Margin like this works fine:
    property Margins margins

But when I try to set the margin like this
    margins: { left: 10; right: 10; top: 10; bottom: 10 }
I get "Unable to assign double to QCpMargins*" errors
(my class is called QCpMargins just not to clash with Qt's QMargins class)

and when I try reading a value:
    Component.onCompleted: print(margins.left)
I get "TypeError: Result of expression 'margins' [null] is not an object." errors.

If I misspell "Margin" in the property definition above I get an error, so the type is definitely found.

Comparing my code with other similar code, everything looks in order, so I'm stumped.
The only difference I can see is that my type does not Q_DECLARE_PRIVATE a 
implementation class, but I don't think that should matter, right?

Any idea what would cause this problem. I'm sure it's something simple...

Thanks!


Cheers
Mathias


More information about the Qt-qml mailing list