Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 44
Registered: ‎02-11-2013
My Device: Z10
My Carrier: TELE2
Accepted Solution

getting Color count

Hi all, I have the following sample code

function test() {
    var col = Color.create(1.0, 0.5, 0.3);
    return col.green();
}

Label {
    text: test()
}

 And the test() function returns nothing. I have no idea why. I expect that it should return 0.5 value. What I'm doing wrong? Any help?  

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: getting Color count

[ Edited ]

Hi,

 

It seems Color's functions aren't invokable from QML:

 

float green() const;

 

A possible workaround is creating helper functions in C++ for accessing Color's members. The second example in this post shows how Color object can be passed from QML to C++:

http://supportforums.blackberry.com/t5/Cascades-Development/Compare-a-labels-color-in-QML/m-p/218616...

An important point: in this code the colors are passed by value. Passing by pointer will not work, because the pointer is not declared as meta-type in Cascades headers.

 


Andrey Fidrya, @zmeyc on twitter