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
Developer
Posts: 49
Registered: ‎11-11-2012
My Device: z10 LE
My Carrier: Digi

.setText() from C++ not setting

Hi,

 

I tried to do e.g. myLabel.setText("Testing 1 2 3") from C++ but the original value ("Original text") is still there.

 

Doing a myLabel.text() shows e.g. "Original text" so the code is looking at the right label QML object.

 

Any hint on what I should check?

 

thanks,
James Tan



James Tan
Eating my dog food - TripLogger, my 1st bb10 app.
Developer
Posts: 49
Registered: ‎11-11-2012
My Device: z10 LE
My Carrier: Digi

Re: .setText() from C++ not setting

Tried another approach, using signal (C++) and slot (QML).

 

Still not able to effect any change on the existing QML object esp the text on it or visibility of components. Any idea?

 

QML:

Page {
    
    //Slot: connected to C++ signal "dataChanged()" in location.hpp.
    //The signal+slot is working based on the console.log with the passed message, but the text update is not. Something is not right.
    function onDataChanged(message) {
            title.text = message;
            locationPageContentProgressIndicator.visible = false ;
            console.log("Debug:"+message);
    }

...

ActivityIndicator {
                id: locationPageContentProgressIndicator
                opacity: 0.7
                visible: true 

...

 

HPP:

Q_SIGNALS:
	void dataChanged(QVariant message);
};

 

CPP:

bool dataChangedConnected = connect(this, SIGNAL(dataChanged(QVariant)),root, SLOT(onDataChanged(QVariant)));

//dataChangedConnected tested in debug log as "true", so this is working. 

 

emit dataChanged("testing");

 

 

 



James Tan
Eating my dog food - TripLogger, my 1st bb10 app.