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
Highlighted
New Contributor
Posts: 9
Registered: ‎09-10-2012
My Device: BlackBerry 9300
My Carrier: T-mobile poland
Accepted Solution

Problem with slot & signals on second Page

[ Edited ]

Hi

 

I would like to build application consisting of two pages.

I use qml to build UI and C++ to build application logic.

 

On the first page singal from controls I recive in C++ code, but on second Page (put on NavigationPane using push) signals not woking. Function connect returns true but singnal not appears in C++ code.

 

SecondPage::SecondPage() {
}

SecondPage::~SecondPage() {
}

bb::cascades::AbstractPane* SecondPage::showPage()
{
	QmlDocument *qml = QmlDocument::create("mainList.qml");
	Page* pageRoot = qml->createRootNode<Page>();
	NavigationPane* navigationPane = TestSlotsApplication::getInstance()->getNavigationPane();

	navigationPane->push(pageRoot);

	if (pageRoot == NULL)
	{
		qDebug("pageRoot == NULL");
		return NULL;
	}
	else
	{
		navigationPane->setBackButtonsVisible(false);
		qDebug("pageRoot != NULL");
	}

	QObject* buttonTest = pageRoot->findChild<QObject*>("buttonTest");
	bool result2 = QObject::connect(buttonTest, SIGNAL(clicked()), this,
			SLOT(buttonOkClicked()));
	if (result2 == true) {
		qDebug("buttonTest connect ok");
	} else {
		qDebug("buttonTest connect error");
	}

	return pageRoot;
}

void SecondPage::buttonOkClicked()
{
	qDebug("buttonOkClicked"); // NEVER SHOWS buttonOkClicked
}

 

 

 If someone would like code put on dropbox: https://dl.dropbox.com/u/464625/Test.zip

Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Re: Problem with slot & signals on second Page

The reference that you are associating with the Signal - Slot is getting changed.

If you would debug your page, you would see in the variable window about the memory address being changed.

Can you place this reference at some other place, which can be referred at a later stage, that way the registered slot will always be fired.
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: Problem with slot & signals on second Page

[ Edited ]

Hi,

 

Actually problem is not in SecondPage class but in FirstPage class.

Just replace buttonOkClicked() function with this code in FirstPage Class.

 

void FirstPage::buttonOkClicked()
{
     SecondPage *page = new SecondPage;
     page->showPage();
}

You have to allocate a memory using new keyword.

 

New Contributor
Posts: 9
Registered: ‎09-10-2012
My Device: BlackBerry 9300
My Carrier: T-mobile poland

Re: Problem with slot & signals on second Page

Thanks for your time raj_jyani. You're right. 

 

Of course. I thought it was something stupid.