Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why when using QT the type of the variables of my scripts change "float" to "int" ?

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.2k Views
  • 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 Offline
    R Offline
    RoiG
    wrote on last edited by RoiG
    #1

    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
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      @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
      0
      • R Offline
        R Offline
        RoiG
        wrote on last edited by
        #3

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

        mrjjM 1 Reply Last reply
        0
        • R RoiG

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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • R Offline
            R Offline
            RoiG
            wrote on last edited by
            #5

            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
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved