[Interest] findChildren() in destroyed() signal slot

Jason Cipriani jason.cipriani at gmail.com
Mon Mar 19 17:12:01 CET 2012


On Mon, Mar 19, 2012 at 12:10 PM, Jason Cipriani
<jason.cipriani at gmail.com>wrote:

> Thanks. I need an accurate list of children in response to a child's
> destroyed signal, so is the best way to do this, then, to have Parent
> maintain its own list of Children, rather than using findChildren(), and
> use the destroyed(QObject*) version of the signal to explicitly remove the
> Child from the Parents list?
>

Or I guess, alternatively, I could set the child's name in destroyed() to
something (e.g. "destroyed") and supply a reg-ex to findChildren() that
does not return children with that name...?

Thanks!
J





> J
>
>
> On Mon, Mar 19, 2012 at 11:52 AM, Thiago Macieira <
> thiago.macieira at intel.com> wrote:
>
>>  On segunda-feira, 19 de março de 2012 11.34.02, Jason Cipriani wrote:
>> > I am new to Qt. I have two QObject-derived classes, Parent and Child.
>> > Child's parent is a Parent. When I attach a slot in Parent to Child's
>> > destroyed() signal, I see that Parent's findChildren() does not include
>> the
>> > Child that was destroyed. This is what I want. Calling findChildren()
>> in a
>> > destroyed() handler, and assuming the child won't be in the list, is
>> safe,
>> > right?
>>
>> Don't assume that.
>>
>> The order in which the signal and the child deletion is run could change
>> in a
>> different version.
>>
>> --
>> Thiago Macieira - thiago.macieira (AT) intel.com
>>  Software Architect - Intel Open Source Technology Center
>>     Intel Sweden AB - Registration Number: 556189-6027
>>     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120319/5205a750/attachment.html>


More information about the Interest mailing list