[Qt-interest] Slot/Signal with one array as argument
Arnold Krille
arnold at arnoldarts.de
Sun Jul 18 15:51:51 CEST 2010
Hi,
On Sunday 18 July 2010 14:13:43 Oswaldo F. Filho wrote:
> I defined in my code two arrays. One in object1 and another in object2.
>
> uint32_t failures[22];
>
> I need to send its from object1 to object2. I writed one connect():
>
> connect(object1, SIGNAL(failuresChanged(const uint32_t*, int)),
> object2, SLOT(setFailures(const uint32_t*, int)));
>
> Where the first argument is the array and the second argument is the
> array's size.
>
> This work well still now! There is another way I do this? Do I pass
> pointer as argument of slots and signal is correct?
You could also use QList/QVector and take advantage of their handling in
signals/slots.
Your current code works, but not in multi-threaded environments.
QList/QVector, when sent across threads, automatically copy the contents (with
only slight overhead as they are implicitly shared). That way when your
sending function delete the list after firing the signal, it will not crash in
multi-thread apps.
And QList/QVector provide more iterators to go through your data:-)
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100718/c3a68045/attachment.bin
More information about the Qt-interest-old
mailing list