2012-11-11 63 views
1

我開始爲我的閃亮新BB10開發Alpha B與Cascades(懷疑我可以在WebWorks上實現功能齊全的Mp3播放器,即使我真的很喜歡),我已經開發一直在努力使QML,並在https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html描述c + +發揮很好,但無論在哪裏,我把產權別名的位置無效

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 
       } 
      } 
     } 
    } 
} 
+0

您應該添加一些上下文,即周圍的代碼。 –

+0

正如我所說,放置它並不重要,它會拋出一個錯誤,但我會把代碼放在上面。 – Machinarius

回答

3

我還沒有完全確定你想要什麼來實現的,但如果你想定義一個別名屬性爲你做簡單的拼寫錯誤artist項目的text屬性:property alias artistText: artist.text是定義別名的正確方法。別名定義的第二部分(點之後的部分)表示目標屬性,這些屬性通常以小寫字母開頭。