Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. eval() in qml
Qt 6.11 is out! See what's new in the release blog

eval() in qml

Scheduled Pinned Locked Moved Solved QML and Qt Quick
13 Posts 4 Posters 3.9k 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.
  • ODБOïO ODБOï

    ah...
    wrapping eval() solved this

    ApplicationWindow{ // my app
      id:root
    ...
      property var warnings : "" 
      property int nbr : 0
    ...
    
        Window{// my testing window
        
          TextInput{
                   id:cmd
                         // i want to write  root.warnings = "warn" 
                         //or  root.nbr = 666
          }
           Button{
                      function evaluate(str){eval(str)} // wrap
            onClicked : evaluate(cmd.text) 
           }
        }
    }
    

    however qt creator still rises the warning

    fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #4

    @LeLev said in eval() in qml:

    evaluate(cmd.text)

    You want to eval user inputted text?! Are you going to vet that text?

    C++ is a perfectly valid school of magic.

    ODБOïO 1 Reply Last reply
    0
    • fcarneyF fcarney

      @LeLev said in eval() in qml:

      evaluate(cmd.text)

      You want to eval user inputted text?! Are you going to vet that text?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #5

      @fcarney said in eval() in qml:

      ?!

      yes (i am the user), see my first comment

      @LeLev said in eval() in qml:

      I want to inject js code to my application for test purposes.

      fcarneyF 1 Reply Last reply
      0
      • ODБOïO ODБOï

        @fcarney said in eval() in qml:

        ?!

        yes (i am the user), see my first comment

        @LeLev said in eval() in qml:

        I want to inject js code to my application for test purposes.

        fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #6

        @LeLev said in eval() in qml:

        I want to inject js code to my application for test purposes.

        Sorry, I totally missed that and went to the code. Maybe you can do it from the C++ side? Return the results to the QML side?

        C++ is a perfectly valid school of magic.

        ODБOïO 1 Reply Last reply
        1
        • fcarneyF fcarney

          @LeLev said in eval() in qml:

          I want to inject js code to my application for test purposes.

          Sorry, I totally missed that and went to the code. Maybe you can do it from the C++ side? Return the results to the QML side?

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by ODБOï
          #7

          @fcarney thx,

          i found exactly what i need, but not tested yet https://github.com/qtproject/qt-solutions/tree/master/qtpropertybrowser

          do you know this project ? do you think i can use it with qtquick project ?

          1 Reply Last reply
          0
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #8

            If you want to modify property for some live debugging, have you checked https://www.kdab.com/development-resources/qt-tools/gammaray/ ?

            ODБOïO 1 Reply Last reply
            2
            • GrecKoG GrecKo

              If you want to modify property for some live debugging, have you checked https://www.kdab.com/development-resources/qt-tools/gammaray/ ?

              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #9

              @GrecKo said in eval() in qml:

              have you checked https://www.kdab.com/development-resources/qt-tools/gammaray/ ?

              No, i will.
              thank you

              1 Reply Last reply
              0
              • ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by ODБOï
                #10

                @GrecKo how to build it ? My QtQuick project uses Qt 13.0 and mingw73_64
                there is a Install.txt file in the project it says :

                 // Building on Windows with MinGW:
                //Make sure you have the path to the MinGW programs in %PATH% first, for example:
                % set "PATH=c:\MinGW\mingw64\bin;%PATH%"
                Now build:
                % mkdir build
                % cd build
                % cmake -G "MinGW Makefiles" ..
                % mingw32-make
                % mingw32-make install
                

                should i use my Qt mingw or a standalone mingw here ?

                jsulmJ 1 Reply Last reply
                0
                • ODБOïO ODБOï

                  @GrecKo how to build it ? My QtQuick project uses Qt 13.0 and mingw73_64
                  there is a Install.txt file in the project it says :

                   // Building on Windows with MinGW:
                  //Make sure you have the path to the MinGW programs in %PATH% first, for example:
                  % set "PATH=c:\MinGW\mingw64\bin;%PATH%"
                  Now build:
                  % mkdir build
                  % cd build
                  % cmake -G "MinGW Makefiles" ..
                  % mingw32-make
                  % mingw32-make install
                  

                  should i use my Qt mingw or a standalone mingw here ?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  @LeLev said in eval() in qml:

                  should i use my Qt mingw or a standalone mingw here ?

                  The one delivered with Qt

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  ODБOïO 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @LeLev said in eval() in qml:

                    should i use my Qt mingw or a standalone mingw here ?

                    The one delivered with Qt

                    ODБOïO Offline
                    ODБOïO Offline
                    ODБOï
                    wrote on last edited by
                    #12

                    @jsulm thx, i will try to build and test gammaray tomorrow

                    1 Reply Last reply
                    0
                    • ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by ODБOï
                      #13

                      It is an awesome tool ! @GrecKo thank you for the suggestion! i knew i will find a tool like this with the help of the forum guys, but this tool even exceed my expectations

                      1 Reply Last reply
                      0

                      • Login

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