I need to support a codebase for Qt 5.15 LTS and Qt 6.2 LTS.
One of the last issues is QVariant::type().
The type of QVariant was deprecated back in 5.x from an enum inside QVariant in favor of QMetaType.
And for some time now I have been casting the return value to QMetaType for compatibility with Qt 6.0:

QMetaType::Type t = (QMetaType::Type)myqvariant.type();

The line above works with 5.15 and 6.0.
However, Qt 6.3 broke this by removing the method QVariant::type() entirely.
I now have to use QVariant::typeId(), which is equivalent to QVariant::metaType().id().
However, neither typeId() nor metaType() exist in 5.15.

That forces me to litter my code with preprocessor defines to distinguish between 5.15 and 6.3, just to get the type in the same format.

Is there any way to find a compromise that gets me the type of the QVariant in a way that works with 5.15 and 6.3?