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
Contributor
Posts: 26
Registered: ‎07-24-2009
My Device: Not Specified

Access a QML Object

Hi there,

 

In one of my classes I have a Q_INVOKABLE function:

 

QDeclarativeEngine engine;
QDeclarativeComponent component(&engine,
QUrl::fromLocalFile("app/native/assets/loadingZones.qml"));
QObject *zonesInstance = component.create();
qDebug() << component.errors();
 
label = zonesInstance->findChild<bb::cascades::Label*>("sLb");
QString labelText = "Test Change";
 
qDebug() << label->text();
label->setText(labelText);
qDebug() << labelText;

 

The qml is pretty simple:

 

  Label {
            id: searchingLabel
            objectName: "sLb"
            text: qsTr("Searching for..")
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            textStyle.lineHeight: 4.5
            textStyle.fontSize: FontSize.Large
        }    

 


qDebug
() << label->text(); -> ouputs "Searching for.."

label->setText(labelText);

qDebug() << label->text(); -> ouputs "Test Change"

 

However, there isn't any change on the screen. What am I doing wrong?

 

Thanks