2013-11-14 239 views
0

我可以賦值給一個變量屬性,但不是在這裏的數組? ...價值不被保留。將值賦給數組,值不保留?

Column { 
    id: table 

    property variant aa: [false, false] //issue... later 
    property variant bb: false //this works 

    ... 

    Button { 
     anchors.top: parent.top 
     anchors.topMargin: 0//40 
     anchors.right: parent.right 
     anchors.rightMargin: 0//50 
     corpFarmAware: true 
     text: tr_NOOP("Next") 

     onClicked: { 
      table.aa[0] = false; 
      table.aa[1] = true; 
      cb0.checked = table.aa[0];//issue of arrays ?? 
      cb1.checked = table.aa[1]; 

      table.bb = true; 
      cb2.checked = table.bb;//WORKS 
     } 
    } 

回答

0

根據QML上variant的文檔:

雖然這是存儲陣列和地圖類型值的便捷方式,你必須知道的項目和屬性上面屬性不QML對象(當然不是JavaScript對象)和屬性中的鍵值對不是QML屬性。相反,items屬性包含一組值,屬性包含一組鍵值對。由於它們被存儲爲一組值,而不是作爲一個對象,其內容不能單獨

我認爲你應該使用var來存儲你的屬性修改。