conversion from 'long' to 'const QJsonValue' is ambiguous
-
I want to insert certain unsigned data types into a QJsonObject, when I try this I get the message to the right of the line, black in a red background:
conversion from 'type' to const QJsonValue' is ambiguousWhere 'type' is actual type name. This occurs on:
uint long ulongIs there anything I can do to fix this, each line looks almost the same with the only difference being the insertion of the type:
objResponse.insert(clsModFileIO::mscszData, lngData); -
@SPlatten
Look at the types accepted byQJsonValueconstructor in https://doc.qt.io/qt-5/qjsonvalue.html. At a guess, yours match eitherintorqint64. So cast your value to whichever of the two you desire?@JonB , thank you, I'm a bit confused as I don't get the warning on:
char uchar int short ushortBut I do get the warning on:
long uint ulongLooking on that page it details:
QMetaType::Int QMetaType::UInt QMetaType::LongLong QMetaType::ULongLong QMetaType::Float QMetaType::DoubleAs all having a destination type of
QJsonValue::Double, but the warnings I'm seeing do not echo that.I've fixed the warnings by adding for each location that has this warning:
qint64 int64Data = static_cast<qint64>(ulngData); objResponse.insert(clsModFileIO::mscszData, int64Data); -
I want to insert certain unsigned data types into a QJsonObject, when I try this I get the message to the right of the line, black in a red background:
conversion from 'type' to const QJsonValue' is ambiguousWhere 'type' is actual type name. This occurs on:
uint long ulongIs there anything I can do to fix this, each line looks almost the same with the only difference being the insertion of the type:
objResponse.insert(clsModFileIO::mscszData, lngData); -
@SPlatten
Look at the types accepted byQJsonValueconstructor in https://doc.qt.io/qt-5/qjsonvalue.html. At a guess, yours match eitherintorqint64. So cast your value to whichever of the two you desire?@JonB , thank you, I'm a bit confused as I don't get the warning on:
char uchar int short ushortBut I do get the warning on:
long uint ulongLooking on that page it details:
QMetaType::Int QMetaType::UInt QMetaType::LongLong QMetaType::ULongLong QMetaType::Float QMetaType::DoubleAs all having a destination type of
QJsonValue::Double, but the warnings I'm seeing do not echo that.I've fixed the warnings by adding for each location that has this warning:
qint64 int64Data = static_cast<qint64>(ulngData); objResponse.insert(clsModFileIO::mscszData, int64Data); -
@JonB , thank you, I'm a bit confused as I don't get the warning on:
char uchar int short ushortBut I do get the warning on:
long uint ulongLooking on that page it details:
QMetaType::Int QMetaType::UInt QMetaType::LongLong QMetaType::ULongLong QMetaType::Float QMetaType::DoubleAs all having a destination type of
QJsonValue::Double, but the warnings I'm seeing do not echo that.I've fixed the warnings by adding for each location that has this warning:
qint64 int64Data = static_cast<qint64>(ulngData); objResponse.insert(clsModFileIO::mscszData, int64Data);@SPlatten
I think, but don't quote me: all of your first 5 are "small" and promote/coerce tointautomatically, and that's what the compiler will pick. For your second group of 3, the ones you are getting the error on, if you think about you can see the compiler can't be sureintwill do it, while preserving sign/value correctly. They might all needqint64to be sure, so that's why it's "ambiguous" between that andint. [Actually, I think you can quote me ;-) ]