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
Regular Contributor
CrozyBB
Posts: 83
Registered: ‎07-19-2012
My Device: Bold 9790, Dev Alpha A
My Carrier: Koodo

Control Layers

Is it possible to set the layering of controls after a qml page has been created? (i.e. bring an object such as label 'to the front' so that it overlaps other objects even though it was originally being overlapped when the page was created)

Please use plain text.
Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

Re: Control Layers

Well you can do so by detaching that element from its last position inside its Container.

 

Add then adding later to a new position inside its container.

 

Here is your qml page creation

 

QmlDocument *qml = QmlDocument::create("main.qml");

 

 

Get references of the parent Control(like a Container) and the control (Button) you want to reposition.

 

Container *mContainer = root->findChild<Container*>("mContainer");

Button *mBtn= root->findChild<Container*>("mButton");  

 

// Similarly there will be many more controls . can refer them to.

 

remove the control from its previous position

 

mContainer->remove(mBtn);

 

then call

 

mContainer->add(mBtn); 

 

// added at last in the parent control

 

this will be very last position. and you will also need to put some changes in layout properties of new Control.

 

you can also create new elements and to your UI after the qml is created .

 

 

Hope this will help

 

 

 

Always Success
Please use plain text.
Regular Contributor
CrozyBB
Posts: 83
Registered: ‎07-19-2012
My Device: Bold 9790, Dev Alpha A
My Carrier: Koodo

Re: Control Layers

I dont believe that is going to work because the element that is coming to the top/front will be an interactive element that is activated on touch by the user.

 

Think of a picture being dragged overtop of another picture. I would like to have every picture that is touched by the user to visually overlay the other pictures as it is being dragged.

 

If you have a playbook, check out the scrapbook app to get an idea of what I'm looking for.

Please use plain text.
Contributor
suhaan
Posts: 10
Registered: ‎09-15-2012
My Device: Curve 9360
My Carrier: Vodafone

Re: Control Layers

I agree to what MFSI says.

 

That will work for sure since its a control object , it will receive touch events.

You will just need to provide the necessary connection between the signals and slots.

Give a try.

 




*****************************************************************************

Why do we fall ? So we might learn to pick ourselves up.
Please use plain text.
BlackBerry Development Advisor (Retired)
gperry
Posts: 138
Registered: ‎05-11-2012
My Device: Developer
My Carrier: Developer

Re: Control Layers

Did these suggestions help you make progress?

 

Graham

Please use plain text.
Regular Contributor
CrozyBB
Posts: 83
Registered: ‎07-19-2012
My Device: Bold 9790, Dev Alpha A
My Carrier: Koodo

Re: Control Layers

The app keeps crashing when I initialize. Here is the code I have.

app.cpp

#include "app.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/Button>
#include <bb/cascades/Container>

using namespace bb::cascades;

App::App()
{
    QmlDocument *qml = QmlDocument::create("main.qml");
    //-- setContextProperty expose C++ object in QML as an variable
    //-- uncomment next line to introduce 'this' object to QML name space as an 'app' variable
    //qml->setContextProperty("app", this);
    
    AbstractPane *root = qml->createRootNode<AbstractPane>();

    Container *mContainer = root->findChild<Container*>("mContainer");

    Button *mBtn= root->findChild<Button*>("mButton");

    mContainer->remove(mBtn);

    Application::setScene(root);
}

 main.qml

import bb.cascades 1.0

//-- create one page with a label and text
Container {
    id: mContainer
    objectName: "mContainer"
    
    Button {
        id: mBtn
        objectName: "mBtn"
        text: "Button 1"   
    }    
    
}

Console  Log:

ERROR:: QNXPpsSubscriptionServer: QNXPpsSubscriptionServer::createObject: (13) Failed to create dir /pps/services/automation/framework

ERROR:: QNXPpsSubscriptionServer: QNXPpsSubscriptionServer::subscribe: Failed to open /pps/services/automation/framework/control?delta,notify=604:00000001


Process 62337228 (Layers) terminated SIGSEGV code=1 fltno=11 ip=79100638(/base/usr/lib/libbbcascades.so.1@+0x44ce0) mapaddr=00100638. ref=00000010

Please use plain text.
Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

Re: Control Layers

Actually you got an error in your qml, you can't make a container control the root of a visual scene


The root of a visual scene in an app must be a subclass of AbstractPane (Page, NavigationPane, TabbedPane).

 

update your main.qml  to

 

import bb.cascades 1.0

//-- create one page with a label and text

Page {
    content: Container {
        id: mContainer
        objectName: "mContainer"
        Button {
            id: mBtn
            objectName: "mBtn"
            text: "Button 1"
        }
    }
}

 

refer this too

 

https://developer.blackberry.com/cascades/reference/bb__cascades__abstractpane.html

 

 

 

 

Always Success
Please use plain text.