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
slashkyle
Posts: 766
Registered: ‎10-16-2012
My Carrier: Telus
Accepted Solution

Manipulate properties of component definition

[ Edited ]

Currently I have containers that are separate pages in main.qml

pages: main.qml, CustomContainer.qml

Page {
  CustomContainer{
     id: myCustomContainer
  }

}

I want to use this

Page {
  attachedObjects: [
    componentDefinition: {
       id: myCustomContainer
       source: "CustomContainer.qml"
    }
  ]

}

I want to make the component definitions so that I can destroy them when not in use however

I'm not sure how to access the properties from CustomContainer afterwards

 

here's a few examples of how i do it now

Page {
  CustomContainer{
     id: myCustomContainer
  }
  
  onSomePropertyAliasChanged: {

  }
}

 or

myCustomContainer.somePropertyAlias = somethingNew

 

 

 

Please use plain text.
Developer
BBSJdev
Posts: 4,906
Registered: ‎07-05-2012
My Carrier: Orange

Re: Manipulate properties of component definition

@slashkyle you wrote...

--

I want to make the component definitions so that I can destroy them when not in use however

I'm not sure how to access the properties from CustomContainer afterwards

--

 

Is this what you meant as obviously after destroying an object you can't access any properties?


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
slashkyle
Posts: 766
Registered: ‎10-16-2012
My Carrier: Telus

Re: Manipulate properties of component definition

[ Edited ]

after creating it, I'm aware the properties can't be access after being destroyed.  and it also no longer takes up memory =)

 

i'm just not sure how to go about accessing the properties after i create a component definition so i can interact with it's content from my main.qml

Please use plain text.
Developer
BBSJdev
Posts: 4,906
Registered: ‎07-05-2012
My Carrier: Orange

Re: Manipulate properties of component definition

[ Edited ]

Okay that makes more sense, you should be able to access in the standard way so for instance creating a property alias in to the componant property you want to change and accessing it through the object you've created...

 

                        myPage.source = "Custom.qml";                        
                        var page = myPage.createObject();                        
                        page.myProperty = "test";    

 

// Custom.qml

Page {
    property alias myProperty: lab.text

    Label {
        id: lab
        text: "Replace me"
    }
}

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.