[Qt-interest] destroyed() signal and sender()

Anthony Serdyukov uksus70 at gmail.com
Tue Dec 2 12:21:03 CET 2008


Hello.

Sample code:

connect(some, SIGNAL(destroyed()), another, SLOT(mournForObject()));

...

void Another::mournForObject()
{
    Some* some = qobject_cast<Some*>(sender());
    if (some == NULL)
        return;

    // I never get here!
}

Some inherits QObject of course. But qobject_cast returns NULL, as
dynamic_cast does too.
Why so?

Though static_cast works well, but it's not safe enough.

-- 
Regards,
Anthony



More information about the Qt-interest-old mailing list