1

我开始使用 Cascades 为我闪亮的新 BB10 Dev Alpha B 进行开发(怀疑我可以在 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
                }
            }
        }
    }
}
4

1 回答 1

3

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

于 2012-11-12T12:47:53.280 回答