HumptyDumptyEIZ
HumptyDumptyEIZ

Reputation: 374

How do I change the label text in one qml file from another qml file using Qt/QML/C++ in Cascades, Blackberry 10?

Say one file in assets folder is RoomDetails.qml:

import bb.cascades 1.0
import "commons"

Page {
    Container {
         PageHeader{}

         //rest of the code
    }  
 }

And the other file in assets/commons folder is PageHeader.qml:

import bb.cascades 1.0


    Container {
         Label {
             id: dynamicLabel
         }

         //rest of the code
     }

Now, I want to change dynamicLabel.text from RoomDetails.qml to 'Room Details' and similarly from other qml files where PageHeader is included. What is the solution to this problem? It can be by using Qt or QML or C++. Thanks in advance.

Upvotes: 1

Views: 1065

Answers (1)

Kunal
Kunal

Reputation: 3535

First, I dont think you need to make Page as a root element of PageHeader.

Follwing is how PageHeader should look and you can define one property title as shown below, which you can access from QML which creates it.

import bb.cascades 1.0

Container {
    property alias title: dynamicLabel.text
    Label {
        id: dynamicLabel
    }
    //rest of the code
}

In RoomDetais QML, you can use PageHeader like below, and access label by accessing it's title property.

import bb.cascades 1.0
import "commons"

Page {
    Container {
         PageHeader{
             title: "Room Details"
         }
         //rest of the code
    }  
 }

Upvotes: 3

Related Questions