Important: Please read the Qt Code of Conduct -

Why when using QT the type of the variables of my scripts change "float" to "int" ?

  • Hello,

    I have a dynamic library A.dll that has a script system (chaiscript).

    When I link this A.dll library with a B.exe program that I use to test the library and execute a script, it works as expected:

    def update() {
    var dt = 0.1f;
    var speed = 50.0f;
    var movement = speed * dt;
    print("dt: " + to_string(dt) + " speed: " + to_string(speed) + " movement: " + to_string(movement));


     dt: 0.1 speed: 50 movement: 5


    When I use QT and link to the same A.dll, and the QT application executes the script using A.dll library it prints this:


     dt: 0 speed: 50 movement: 0

    As you can see the floating variables are truncated to INT.

    Anyone knows if QT is doing something weird with the built-in types?
    Thank you!

  • Lifetime Qt Champion

    @RoiG said:


    Make sure u are using QString::number to convert for output
    float pi = 3.14;
    QString b = QString::number(pi);

    Else It should not fux with the types.

    Edit: sorry , Py . Not sure that the actual issues.

  • Hello, thank you for your answer but the to_string method is a method from chaiscript script system not the QT one.

    I'm not using the QT types for the script, just built-in types like int float etc..

  • Lifetime Qt Champion

    well seems a bit odd.
    Does this apply to all py variables u define?

  • py == python? It's chaiscript, and yes it happens to all variables that I define :(

    I asked the same on the chaiscript forum, the main programmer of chaiscript, said the same "That's very odd" :P

    I suppose that I will have to make an small test case..

    Thank you! :)

  • Lifetime Qt Champion

    sorry. my bad.
    Its was the "def" that made my brain go py.

    yeah I think u need a small test case as Qt should not mess with the build in types as far as I know
    since it has its own ones. quint32 etc.

    Good luck!

Log in to reply