[Development] Applications using -fno-rtti
Konstantin Tokarev
annulen at yandex.ru
Sat Jun 20 21:27:16 CEST 2020
20.06.2020, 22:12, "Allan Sandfeld Jensen" <kde at carewolf.com>:
> On Samstag, 20. Juni 2020 21:00:27 CEST Alberto Mardegan wrote:
>> On 20/06/20 21:42, Konstantin Tokarev wrote:
>> > Comparing metaObject() with staticMetaObject() is wrong because it would
>> > fail even for QProcess.
>>
>> I didn't try, but why would it fail?
>>
>> > OTOH, using qobject_cast would handle classes derived
>> > from QProcess correctly, unlike code with typeid().
>>
>> But how would you use qobject_cast in this case? We don't know what
>> class to cast to; we only want to know if we are a subclass of QProcess.
>
> Can't you just check if a cast to QProcess succedes or fails then?
>
Sorry, I haven't read the context carefully. In this particular case it's known
that q is always instance of QProcess or derived class, and subject code
distinguishes QProcess base class from derivatives.
In this case, qobject_cast is not appropriate and it seems like comapring
className() is a way to go.
--
Regards,
Konstantin
More information about the Development
mailing list