属性别名的位置无效

时间:2012-11-11 04:30:05

标签: qt qml blackberry-10 blackberry-cascades

我开始为我的闪亮新BB10 Dev Alpha B开发Cascades(怀疑我可以在WebWorks上实现一个功能齐全的Mp3播放器,即使我真的很喜欢)而且我已经尝试使QML和C ++很好地发挥,如https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html所述,但无论我把它放在哪里

property alias artistText: artist.Text

QNX Momentics IDE抱怨它位于无效的地方。我还没有找到关于这些属性应该在哪里的指导,所以我决定在这里问。

import bb.cascades 1.0

Page {
    actionBarVisibility: ChromeVisibility.Visible
    Container {
        layout: DockLayout {

        }
        Button {
            text: "Random"
            verticalAlignment: VerticalAlignment.Top
        }
        Button {
            text: "Repeat"
            horizontalAlignment: HorizontalAlignment.Right
        }
        Container {
            verticalAlignment: VerticalAlignment.Center
            ImageView {
                preferredWidth: 615.0
                preferredHeight: 615.0
                minWidth: 615.0
                minHeight: 615.0
                maxWidth: 615.0
                maxHeight: 615.0
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
                imageSource: "asset:///test.jpg"
            }
            Container {
                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Bottom
                topMargin: 60.0
                Label {
                    id: artist
                    text: "Artist"
                    horizontalAlignment: HorizontalAlignment.Center
                }
                Label {
                    id: song
                    text: "Track"
                    horizontalAlignment: HorizontalAlignment.Center
                }
                Label {
                    id: album
                    text: "Album"
                    horizontalAlignment: HorizontalAlignment.Center
                }
                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    Button {
                        text: "Previous"
                    }
                    Button {
                        text: "Pause"
                    }
                    Button {
                        text: "Next"
                    }
                }
                Slider {
                    verticalAlignment: VerticalAlignment.Bottom
                    horizontalAlignment: HorizontalAlignment.Center
                    fromValue: 0
                    toValue: 100
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:3)

我仍然不能完全确定您想要实现的目标,但是如果您想为text项的artist属性定义别名属性,则会产生简单的拼写错误:property alias artistText: artist.text是定义别名的正确方法。别名定义的第二部分(点后面的部分)表示目标属性,这些属性通常以小写字母开头。