Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    6
    991
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RoiG last edited by RoiG

      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));
      .....
      

      prints:

       dt: 0.1 speed: 50 movement: 5
      

      NOW THE PROBLEM:

      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:

      prints:

       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!

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        @RoiG said:

        to_string

        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.

        1 Reply Last reply Reply Quote 0
        • R
          RoiG last edited by

          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..

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @RoiG last edited by

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

            1 Reply Last reply Reply Quote 0
            • R
              RoiG last edited by

              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

              http://discourse.chaiscript.com/t/inconsistency-of-var-type-between-executions/171

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

              Thank you! :)

              1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion last edited by

                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!

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post