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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
Curahee
Posts: 122
Registered: ‎01-12-2013
My Carrier: -
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.

______________________________________________________
Voetbal afgelast in België? Check at AppWorld
Please use plain text.
Developer
Zmey
Posts: 883
Registered: ‎12-18-2012

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 *>");
Please use plain text.
Developer
Curahee
Posts: 122
Registered: ‎01-12-2013
My Carrier: -

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!

______________________________________________________
Voetbal afgelast in België? Check at AppWorld
Please use plain text.
Developer
Curahee
Posts: 122
Registered: ‎01-12-2013
My Carrier: -

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.

______________________________________________________
Voetbal afgelast in België? Check at AppWorld
Please use plain text.
Developer
Zmey
Posts: 883
Registered: ‎12-18-2012

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:

 

Please use plain text.