Solved Value instead of .toFloat
-
Hey i have the following code:
QVariant x = .......; return x.toFloat();
I read the x AND the type from a JSON-File.
So i wanted very dynamically, i search something like
pseudocode:QVariant x = .....; return x.type(type read from the JSON-File as a String);
Do you have a possibility where i can set the type as a String ?
-
return x.type(type read from the JSON-File as a String);
How should that work? Your function needs a definite return type, so you cannot decide within the function what you want to return.
You can of course, convert the variant to a string always...
-
Hey @aha_1980,
i think there is a way with "type" ... but i dont know exactly.
I want to set the type dynamically ....
But thank you for your request
-
@NotYourFan said in Value instead of .toFloat:
i think there is a way with "type" ... but i dont know exactly.
No, in C++ this is not possible. That's why variants exist in the first place.
-
@aha_1980
thx, i solved my problem now with regex :) -
@NotYourFan Then please mark this topic as SOLVED too. Thanks!