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: 281
Registered: ‎05-31-2012
My Device: Playbook
My Carrier: o2
Accepted Solution

property var not working in qml?

hi, i have the following code where i want to use 2 properties:

// Default empty project template
import bb.cascades 1.0

// creates one page with a label
Page {
    property var aString: "Hello world!"
    property var aInt: 100
    
    Container {
        layout: DockLayout {}
        Label {
            text: qsTr("Hello World")
            textStyle.base: SystemDefaults.TextStyles.BigText
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
        }
    }
}

 but the IDE says: 

Multiple markers at this line
- Syntax error; mismatched token
- no viable alternative at input ':'
- Unknown property

 

what is wrong there? in the QML docu its right: http://doc-snapshot.qt-project.org/5.0/qml-var.html

Plase "+Like" my post if it was helpful.
Developer
Posts: 251
Registered: ‎11-22-2011
My Device: Blackberry Playbook
My Carrier: vodafone

Re: property var not working in qml?

"aString" and "aInt" are not valid datatypes in Cascades. Use the javascript datatypes instead, like "String", "int" etc.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: property var not working in qml?

Cascades is not yet based on QML 5.0, so I think you're looking at the wrong place.

 

Try http://qt-project.org/doc/qt-4.8/qdeclarativebasictypes.html instead, which shows "variant" as the older equivalent to "var", from what I can tell.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 55
Registered: ‎02-17-2013
My Device: Z10 LE
My Carrier: Tata Docomo

Re: property var not working in qml?

[ Edited ]

I am facing a similar kind of issue. This time with int . 

Is Cascades still on Qt4.8?

Also could someone explain the meaning of no viable alternative at input  error?

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: property var not working in qml?

Yes, still 4.8. Can't help with the other question.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!