Solved eval() in qml
-
I want to inject js code to my application for test purposes.
i wanted to use js eval() function but qt creator said don't use eval (M23)
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{ onClicked : eval(cmd.text) } } }
is this possible with something else than eval()
thanks -
ah...
wrapping eval() solved thisApplicationWindow{ // 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
-
i just saw this project https://github.com/qtproject/qt-solutions/tree/master/qtpropertybrowser
this is exactly what i need, does someone know if i can use this with QtQuick QML application ?
-
@LeLev said in eval() in qml:
evaluate(cmd.text)
You want to eval user inputted text?! Are you going to vet that text?
-
@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.
-
@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?
-
@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 ?
-
If you want to modify property for some live debugging, have you checked https://www.kdab.com/development-resources/qt-tools/gammaray/ ?
-
@GrecKo said in eval() in qml:
have you checked https://www.kdab.com/development-resources/qt-tools/gammaray/ ?
No, i will.
thank you -
@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 ?
-
@LeLev said in eval() in qml:
should i use my Qt mingw or a standalone mingw here ?
The one delivered with Qt
-
@jsulm thx, i will try to build and test gammaray tomorrow
-
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