4 ms·
How do you use QMetaType::type without having to do the same as I said, which is explicit casting? afaik there's no way to get the 'real' type that you can shov
by devwastaken 8y ago
How do you use QMetaType::type without having to do the same as I said, which is explicit casting? afaik there's no way to get the 'real' type that you can shove into qobject_cast or dynamic_cast to turn QWidget into a QLineEdit. The only way is to write in the type and try each cast, you can't store types in some map and go 'get' the type at runtime to have casted.
- ahartmetz 8y agoYes you will have to cast eventually, and no you won't have to try casts.
- devwastaken 8y agoYou'd have to point out specific code for that. Afaik that's not possible in c++ at runtime. Compiler has to know the type even in dynamic casting.
- ahartmetz 8y agoI actually think I've given you all the info you need. You switch on type ID and cast to the then known type.