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
Curahee
Posts: 226
Registered: ‎01-12-2013
My Device: z30
Accepted Solution

emitting signal with QList as parameter?

Hey Developers

 

How can I pass a QList as an argument with a signal? He keeps saying

 

"No such signal ConnectionService::downloadCompleted(QList, QString)"

 

I'm emitting the signal with a QList<Connection*> object and a QString. This is my signal

 

void downloadCompleted(const QList<Connection*> &connections, const QString &error);

 And this is how I connect

 

connect(&this->connectionService, SIGNAL(downloadCompleted(QList, QString)), this, SLOT(searchCompleted(QList, QString)));

 I allso tried QList<Connection*> as SIGNAL signature. But that did not work either.

 

Thanks in advance.

______________________________________________________
BB10-OAuth: GitHub
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: emitting signal with QList as parameter?

[ Edited ]

Pass a complete type, i.e.

connect(&connectionService, SIGNAL(downloadCompleted(const QList<Connection*>&, const QString&)), this, SLOT(searchCompleted(const QList<Connection *>&, const QString&)));

"const" and "&" can be omitted so this should also work:

connect(&connectionService, SIGNAL(downloadCompleted(QList<Connection*>, QString)), this, SLOT(searchCompleted(QList<Connection *>, QString)));

 

upd:

Try registering the type:

qRegisterMetaType< QList<Connection *> >("QList<Connection *>");

Andrey Fidrya, @zmeyc on twitter
Developer
Curahee
Posts: 226
Registered: ‎01-12-2013
My Device: z30

Re: emitting signal with QList as parameter?

That's weird, I thought I allready tried that. But hey, it works, I'm happy :smileyhappy:.

 

Thanks again!

______________________________________________________
BB10-OAuth: GitHub
Developer
Curahee
Posts: 226
Registered: ‎01-12-2013
My Device: z30

Re: emitting signal with QList as parameter?

And is it also possible to do it like this:

 

void downloadCompleted(const QList<Connection*> *connections, const QString &error);

 

connect(&connectionService, SIGNAL(downloadCompleted(QList<Connection*>*, QString)), this, SLOT(searchCompleted(QList<Connection*>*, QString)));

 Because that does not seem to work anymore. Don't know if it's possible to pass a pointer with a signal.

______________________________________________________
BB10-OAuth: GitHub
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: emitting signal with QList as parameter?

[ Edited ]

Try registering QList<Connection *>* using qRegisterMetatype. It should work, but I think it's better to pass QList itself so you don't have to track it's lifetime.

Qt containers are copy-on-write anyway so this operation shouldn't be time consuming.

 

Even foreach() makes a copy of it's container before iteration. :smileyhappy:

 


Andrey Fidrya, @zmeyc on twitter