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
New Developer
Posts: 168
Registered: ‎04-12-2010
My Device: Storm
My Carrier: Verizon

signal connect fails no matter what?

Perhaps someone can shed some light over this issue, I want to forward a signal to another class but it is failing pretty badly all the permutations I have tried so far always have the connect  returning False, tried it anyway of course the method doesn't trigger, double check the hpp file several times

 

 

BT_Manager::BT_Manager(QObject *parent)
: QObject(parent)
, m_class_2_receive_signal(new class_2_receive_signal(this))
{
   bool res;
  // this one works returns true and the message is recvd 
   res = connect(&m_sppDataThread, SIGNAL(msgRcvd(QString)), SLOT(msgRcvd(QString)));
   
   // something as basic as this does not work. returns false 
   res =  connect(this, SIGNAL(msgRcvd_fwd(QString)),
			m_class_2_receive_signal,  SLOT(msgRcvd(QString)));
			
   //tried this one just 4 kicks same result(FALSE)		
   res =  connect(this, SIGNAL(obdMsgRcvd_fwd(QString)), qApp, SLOT(aboutQt()));
   .
   .
   .
}   
   
void BT_Manager::msgRcvd(const QString &message)
{
	//do stuff -- debugger gets here so it is fine at that
	
    //forward the msg now
    emit msgRcvd_fwd(message);
}

 

Time is tight and I'm about to throw the towel on this option and just tweak it to get something working, what is the performance issue/penalty if I get this working message to set a TextField in the qml file and then from there "forward" the message back(using the onTetxtChanged) to my other class I think I can get that one working in no time 

 

 

 

 

Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: signal connect fails no matter what?

Hey there,

 

Curious.. does your other class have a SLOT function declared as msgRcvd(QString) ? I'll assume that you have all of your signals and slots declared in your HPP files...

 

What does the log file say if anything?  It should show you any errors with the connect()...

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: signal connect fails no matter what?

At run time you should see an error message pop up indicating a cause of the connect failure. Can you post that error message?

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: signal connect fails no matter what?

Did you run the Q_OBJECT macro? For example:

 

class HomeScreenController : public ViewController {
	Q_OBJECT
public:
..etc..

 If you don't have the Q_OBJECT macro, add it to your header like I show above and do a project clean. Without doing a project clean after adding the Q_OBJECT macro you will get a vtable error during compile.

New Developer
Posts: 168
Registered: ‎04-12-2010
My Device: Storm
My Carrier: Verizon

Re: signal connect fails no matter what?

What it needed was a new name,  defined a new name for the SIGNAL, same signature and like magic it worked the return value of the connect was true so that was a good sign and stepping thru the debugger proved the target slot was being called as my breakpoint was hit ... when it failed it wouldn't do anything in the sense my breakpoint on the SLOT func would not stop. No extra messages or anything. Just nothing and I'm debugging with a device as I had simulator issues.

 

  I'm running 10.1.0.1020 which I think is the latest incarnation(not the greatest yet?)  a few times a small change would trigger lots of those undefined/moc this/that,  nothing but a Clean would get it back or sometimes a restart but I've seen that with the Android plugin also.

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: signal connect fails no matter what?

The signal name likely was not the problem so much as the project just needed to be cleaned. Momentics will try and only compile source files that have changed, but some code changes do not seem to get detected which makes for a mess of confusing compiler errors that you won't be able to fix by debugging code. 

 

Scott