[Qt-interest] Force the emission of a signal

Andrea Franceschini therealmorpheu5 at gmail.com
Mon Mar 23 13:00:16 CET 2009


2009/3/22, Rohan McGovern <rohan.mcgovern at nokia.com>:

> Assuming you have MyObject* obj:
>
> if (!QMetaObject::invokeMethod(obj, "signal"))
>   Q_ASSERT(0);

*astonishment*.

This is exactly what I was looking for... why did I miss it? Oh,
right, I didn't look into QMetaObject :)

Anyway after a bit of analysis, I decided to go the other way, at
least for now. The reason is that I have some visual controls that
need to act like widgets, but for oh-so-many reasons I can't use
QWidgets (at least not right now). So, for example, if one of these
visual controls is "tapped", it would be mostly useful to also make it
execute something in a tap() slot before emitting the tapped() signal.

Yes, one may suggest to exchange the order and connect the tap() slot
to the tapped() signal :) I'll evaluate this possibility.

Anyway thank you Rohan.

-- 
Andrea



More information about the Qt-interest-old mailing list