0

Cascades, 10.2 SDK

MyCustomContainer.qml:

import bb.cascades 1.2

Container {
    id: rootContainer

    Container{
        id: childContainer
        // some content
    }   
}

MyPage.qml:

import bb.cascades 1.2

Page {

    MyCustomContainer{

         Label{
              id: label
         }
    }
}

Label will be added on top of all content inside the rootContainer. I'd like to insert the label(or any other content) below all the content in MyCustomContainer. I've tried creating a property inside MyCustomContainer:

property Container backgroundContent

and add it as first child inside the MyCustomContainer as:

id: rootContainer

backgroundContent{
    id: backgroundContent
}

and just set it in MyPage as:

MyCustomContainer{
     backgroundContent: Container{

     }

but I get

Cannot assign to non-existent property "id"

since the property value has not been set.

Can I somehow insert the content from MyPage.qml at the root of the MyCustomContainer?

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Mercurial
  • 2,095
  • 4
  • 19
  • 33

3 Answers3

0

It sounds like you want to use a default property to assign any children of the MyCustomContainer to be placed into the childContainer.

import bb.cascades 1.2

Container {
    id: rootContainer

    default property content: childContainer.children

    Container{
        id: childContainer
        // All children when this control is used will be placed inside this component.
    }   
}

Then it can be naturally used as:

MyCustomContainer {
     Container {

     }

This will render the Container within the childContainer of the MyCustomContainer component.

Deadron
  • 5,135
  • 1
  • 16
  • 27
  • I'm getting `mismatched input '.' expecting COLON`. `default property alias content` fixes the issue, but then I get `Invalid alias location`. It looks like there is no children property on Container? – Mercurial Dec 04 '13 at 10:11
  • There should be children on every component. Its a property on QObject. Are you sure you put a colon after the alias name? – Deadron Dec 04 '13 at 14:19
  • There is no children property in Cascades AFAIK. – Mercurial Jan 27 '14 at 20:39
  • 1
    Random blast from the past here. Unless cascades provides its own custom QObject implementation it should be there. I suppose it could be that bb cascades uses a version of QT before I started working with it that did not have it. – Deadron Jan 27 '14 at 20:41
0

Try using backgroundContent.add()

Ebscer
  • 27
  • 1
  • 7
0

The solution is rather simple. Predict at which place can components be injected in the root container and place another container there.

Container {
id: rootContainer

Container{
    id: injectContainer
}

Container{
    id: childContainer
    // some content
}   
}

injectContainer.add(label)
Mercurial
  • 2,095
  • 4
  • 19
  • 33