qt:按钮的无效属性名称“x"(M16) [英] qt: invalid property name 'x' (M16) for button

查看:46
本文介绍了qt:按钮的无效属性名称“x"(M16)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 QtCreator 3.3.1 中使用 Qt 5.4.1

I'm using Qt 5.4.1 in QtCreator 3.3.1

我已将 QtQuick.Controls 1.2 导入我的 QML 并添加了一系列按钮:

I've imported QtQuick.Controls 1.2 into my QML and added a series of buttons:

Rectangle {
    id: buttonBar
    x: 480
    y: 0
    width: 320
    height: 80
    Button {
        x: 0
        y: 0

        width: 80
        height: 60

        text: "Songs"
    }

    Button {
        x: 80
        y: 0

        width: 80
        height: 60

        text: "Artists"
    }

    Button {
        x: 160
        y: 0

        width: 80
        height: 60

        text: "Albums"
    }

    Button {
        x: 240
        y: 0

        width: 80
        height: 60

        text: "Back"
    }
}

当我运行程序时它们都渲染得很好,但是每次 QtCreator 打开 qml 文件时它都会跳转到设计模式并且我收到警告:

They all render fine when I run the program, but everytime that QtCreator opens the qml file it jumps into design mode and I get the warning:

invalid property name 'x' (M16) 

当我在编辑模式下查看文件时,我使用 x、y、宽度和高度的行都带有下划线.

and the lines where I use x, y, width and height are all underlined when I view the file in edit mode.

但是文档说这些是我的按钮的有效属性 - http://doc.qt.io/qt-5/qml-qtquick-controls-button-members.html

But the documentation says these are valid properties for my buttons - http://doc.qt.io/qt-5/qml-qtquick-controls-button-members.html

如何停止/解决此错误消息?

How do I stop/resolve this error message?

推荐答案

这是为使用 Qt Creator 的控件生成的类型信息中的一个错误.

It's a bug in the type info that is generated for controls for use of Qt Creator.

要抑制此错误,请添加注释:

To suppress this error, add comment:

Button {
    // @disable-check M16
    x: 80
    y: 0
}

这篇关于qt:按钮的无效属性名称“x"(M16)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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