fix: float is handled as double for QVariant and QMetatype, float32 is float

This commit is contained in:
Ivan Belyakov 2024-04-12 11:23:34 +02:00
parent 13a8890db4
commit ef8b329518
3 changed files with 10 additions and 4 deletions

View File

@ -91,8 +91,8 @@ proc fromQVariantConversion(x: string): string {.compiletime.} =
of "int": result = "intVal"
of "string": result = "stringVal"
of "bool": result = "boolVal"
of "float": result = "floatVal"
of "double": result = "doubleVal"
of "float32": result = "floatVal"
of "float": result = "doubleVal"
of "QObject": result = "qobjectVal"
of "QVariant": result = ""
else: error("Unsupported conversion from QVariant to $1" % x)
@ -106,8 +106,8 @@ proc toMetaType(x: string): string {.compiletime.} =
of "int": result = "Int"
of "bool": result = "Bool"
of "string": result = "QString"
of "double": result = "Double"
of "float": result = "Float"
of "float": result = "Double"
of "float32": result = "Float"
of "pointer": result = "VoidStar"
of "QVariant": result = "QVariant"
of "QObject": result = "QObjectStar"

View File

@ -75,6 +75,7 @@ type
UnknownType = 0.cint,
Bool = 1.cint,
Int = 2.cint,
Double = 6.cint,
QString = 10.cint,
VoidStar = 31.cint,
Float = 38.cint,

View File

@ -92,6 +92,11 @@ proc newQVariant*(value: QVariant): QVariant =
result.setup(value)
proc newQVariant*(value: float): QVariant =
## Return a new QVariant given a float
new(result, delete)
result.setup(value.cdouble)
proc newQVariant*(value: float32): QVariant =
## Return a new QVariant given a float
new(result, delete)
result.setup(value.cfloat)