I have realized that QVariant does not offer functionality for long
and unsigned long
. It offers conversions to int
, unsigned int
, long long
and unsigned long long
.
We can find in current Desktop architectures that long
and int
are equivalent, but they are not from a theoretical point of view.
If I want to store a long
in a QVariant
I am obligated to convert first the value to long long
. I would like to know if there is any other way to overcome this.
Secondly, I am interested to know the better/simpler way to do it. I.e. using a simpler code, and avoiding the use of unnecessary space or instructions.
It's very likely (according to the question title) that topic starter has received the following error message from the compiler:
error: conversion from ‘uint64_t {aka long unsigned int}’ to ‘QVariant’ is ambiguous
None of the answers suggested provides a simple solution. So, instead of implicit conversion from a value, something like
QVariant_value = long_unsigned_int_value;
try the following:
QVariant_value = QVariant::fromValue(long_unsigned_int_value)
This helped me.