QML - 不支持命令性代码 [英] QML - Imperative code not supported

查看:631
本文介绍了QML - 不支持命令性代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以评论 QML ,任何命令式 JavaScript 代码都不会执行,除非它是的额外组件。当我在我的QML中包含下面的代码时,我面临这样的问题:

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";
}

由于Qt Designer被冻结并显示以下警告:

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

Imperative code is not supported in the Qt Quick Designer

我阅读了构建 qmlpuppet 的安装可执行文件的 / bin 目录下的Qt建立它。如果qmlpuppet位于/ bin目录中,则 Qt Quick Designer 会检查当前项目的Qt。如果是,它需要由Qt版本提供的qmlpuppet,而不是由Qt Creator提供的。在我的情况下,我没有使用Qt静态二进制安装,而是从源代码构建Qt,因此已生成qmlpuppet 可执行文件,并已位于以下位置:

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

因此,可执行文件qmlpuppet被放置在预期被找到的地方,并且这个讨厌的消息继续。

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

我立刻采取的解决方法是注释掉任何所谓的命令式代码,当我想使用Qt Designer编辑前端QML时。然后在取出这些意见后,再次激活命令性代码。但这是非常讨厌,虽然代码编译和工作,我预期它的行为。

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.

那么,我应该担心这个警告吗?无论如何,有一些手段来摆脱这个问题,因为它冻结了Qt设计器?

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?

推荐答案

QtCreator Bug:

This is currently a reported QtCreator Bug :

https://bugreports.qt-project.org/browse/QTCREATORBUG-10940?page=com.atlassian.streams.streams-jira-plugin:activity-stream-问题标签

因此,不要担心警告,这将是修复

So don't be worried about the warning, it will be fix

这篇关于QML - 不支持命令性代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆