QML - Imperative code not supported

4k Views Asked by At

Can someone comment on the fact that for QML, any imperative JavaScript code is not executed unless it is part of an extra component. I am facing such kind of problem when I include the following code to my QML:

function qmlSlot(text){
    page.data=text
    if(page.data==="received")
        page.color="black";
}

As the Qt Designer get frozen and shows the following warning:

Imperative code is not supported in the Qt Quick Designer

I read that building qmlpuppet installs an executable for rendering components in the /bin directory of the Qt building it. Qt Quick Designer checks for the Qt of the current project if a qmlpuppet is in the /bin directory. If yes it takes the qmlpuppet provided by the Qt version instead of the one provided by Qt Creator itself. In my case I haven't used the Qt static binary install, but instead built Qt from the source, thus qmlpuppet executable was generated and is already located at:

/usr/local/Qt-5.2.1/qtcreator/bin
-rwxr-xr-x  1 qml2puppet
-rwxr-xr-x  1 qmlpuppet

So, the executable qmlpuppet is placed where is expected to be found and still this annoying message continues.

The workaround I took at moment is to comment out any so called "Imperative code" for when I want to edit the front-end QML using Qt Designer. Then after take out those comments to have the "Imperative code" activated again. But this is very annoying, although the code compile and works as I expected it to behave.

So, should I get worried about this warning? Anyway, there is some mean to get rid of this problem, as it froze the Qt Designer?

1

There are 1 best solutions below

0
BlueMagma On BEST ANSWER