[Qt-interest] emit custom built objects in signal/slot

Srdjan Todorovic todorovic.s at googlemail.com
Tue Sep 15 16:38:39 CEST 2009


Hi all,

On 15/09/2009, Ulf-Alexander v. Ceumern-Lindenstjerna
<ceumern at vrmagic.com> wrote:

> void stuff
> {
> 	MyClass l_data;
> 	emit stuffHappened(l_data);
> }

> But now, as I think about it, what about l_data lifetime? Do I need to
> make sure it exists long enough?

I've not looked up the documentation specifically, but as far as I
understand it, if the connection is a direct connection, then the emit
line will be effectively:

 	 stuffHappened(l_data);

as in a function call, and things will be OK. If the connection is a
queued connection, then there may be a problem that the object goes
out of scope before/during use in the slot.

Srdjan



More information about the Qt-interest-old mailing list