So far in my project where I had to store different data types in one place and in the end send them through a medium bytewise, I always used a custom union:
union union64_t
{
quint16 u16[4];
qint16 i16[4];
quint32 u32[2];
qint32 i32[2];
float f32[2];
quint64 u64;
qint64 i64;
double f64;
};
Is there a way to use Qvariant
instead of this union? Even If I assign a q variant with something, ie:
Qvariant test(1.25f);
How can I extract it as bytes (assuming it was a double
or float
type)? I would appreciate all help.