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: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Signal not emit when set content of Tab from C++

[ Edited ]

Hi,

 

i am developing application which set content of tab from C++ but when i set content of tab from c++ any signal not working . only not working on os 10.1 while on 10.2 working fine. anyone know alternate solution for it.

 

Here is my code

 

Main Qml

 

import bb.cascades 1.0

TabbedPane {
    objectName: "tabbed"
    Tab {
        title: "Home"
        objectName: "tabHome"
        //content: CustomScreen {
        //}
    }
}

 CustomScreen QML

 

import bb.cascades 1.0

Page {
    content: Container {
        Button {
            text: "Test"
//this event never fire on os 10.1 onClicked: { console.log("Got click event"); } } } }

 C++ code

 

#include "applicationui.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/Tab>

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
		QObject(app) {
	QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	AbstractPane *root = qml->createRootObject<AbstractPane>();
	app->setScene(root);

	Tab *tab = root->findChild<Tab *>("tabHome");

	QmlDocument *qmlScreen = QmlDocument::create("asset:///CustomScreen.qml");
	AbstractPane *rootScreen = qmlScreen->createRootObject<AbstractPane>();

	tab->setContent(rootScreen);
	
}

 

Thank You

 

New Contributor
Posts: 5
Registered: ‎06-22-2011
My Device: Z10, Playbook, SGS2
My Carrier: Bell/Rogers

Re: Signal not emit when set content of Tab from C++

You are not alone.  I was just playin with the 'Hello World' tutorial and added a button.  The 'onClicked' event never emits a signal which puts a big crimp in the learning process.   PyQT was much less aggravating than this!

New Contributor
Posts: 5
Registered: ‎06-22-2011
My Device: Z10, Playbook, SGS2
My Carrier: Bell/Rogers

Re: Signal not emit when set content of Tab from C++

Figured out part of my problem; Eclipse recognizes the "console.log" portion while neglecting the need to have a message handler for it (it's not part of the template.) See here for the gist of it: http://rapidberry.net/logging-from-qml-and-c/
Regular Contributor
Posts: 205
Registered: ‎06-11-2013
My Device: Blackbery z10
My Carrier: RIM

Re: Signal not emit when set content of Tab from C++

By saying not executing you mean this line 

console.log("Got click event");
never executes?
New Contributor
Posts: 5
Registered: ‎06-22-2011
My Device: Z10, Playbook, SGS2
My Carrier: Bell/Rogers

Re: Signal not emit when set content of Tab from C++

Strictly speaking, it executes but the message never gets passed.  In your main.cpp template add:

 

void messageLogger(QtMsgType type, const char *msg) {
std::fprintf(stdout, "%s\n", msg);
std::fflush(stdout);
}

 above the Q_DECL_EXPORT... etc line
 and

qInstallMsgHandler(messageLogger);

 just after the "Application app(argc, argv);

 

I had just assumed, after reading all the examples that have logging code, that this was part of the template in the IDE.

 

Cheers,

 

Todd

Regular Contributor
Posts: 205
Registered: ‎06-11-2013
My Device: Blackbery z10
My Carrier: RIM

Re: Signal not emit when set content of Tab from C++

console.Log is little tricky. 

Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: Signal not emit when set content of Tab from C++

Hi,

 

Thank you for your reply, but it's working on 10.2 os simulator and device both. not working only os 10.1 both simulator and device. on 10.1 os if i uncomment content: CustomScreen { } and comment //tab->setContent(rootScreen);

thenk it's work . only not work when i set content of tab from c++ . just try by making simple example

 

 

 

Thank You

Regular Contributor
Posts: 205
Registered: ‎06-11-2013
My Device: Blackbery z10
My Carrier: RIM

Re: Signal not emit when set content of Tab from C++

I have to try this.