Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find syntax errors in QML files?

I'm doing development for Blackberry 10 using Cascades, which includes QT and QML. I find that I sometimes make mistakes in my QML file, but they don't get picked up at compilation time. How can I check whether I've made a syntax error, or mis-named a function call, or other typical errors?

like image 507
paulmorriss Avatar asked Mar 11 '13 09:03

paulmorriss


People also ask

How do I edit a QML file?

In Projects, double-click a . qml file to open it in the code editor. Then select the Design mode to edit the file in the visual editor.

How do I run a QML code?

Creating and Running QML Projects For simple UI files such as this one, select File > New File or Project > Application (Qt Quick) > Qt Quick Application - Empty from within Qt Creator. Pressing the green Run button runs the application.


1 Answers

QML is a dynamic language that is evaluated at Runtime. There is no compilation step and due to the nature of javascript and the dynamic nature of the global context there is no way for it to tell if what you are writing is correct/incorrect until it is evaluated. QtCreator can help with some of the QML errors you will find, but there is unfortunately no good way to get syntax errors about your javascript until it is evaluated and it explodes.

Personally, I have found good usage of the debugger to be the key to making these sort of fixes easy.

tldr; Keep your javascript clean and to a minimum there is no compile time checking.

like image 184
Deadron Avatar answered Sep 18 '22 19:09

Deadron