2014-09-13 3 views
0

만 한 행 볼 수있는 TableView :QML : 다음 코드에서 행 및 항목 대표

Rectangle{ 
    width: { parent==null ? 640: parent.width } 
    height: { parent==null ? 480: parent.height } 

    Image { 
     id: mainBackground 
     anchors.fill: parent 
     source: "qrc:///wallDiscoveryBackground" 
     fillMode: Image.PreserveAspectFit 

     TableView { 
      id: wallDiscoveryTable 
      anchors.margins: parent.width * 0.6 
      width: parent.width 

      clip: true 

      model: discoveredWallsTableModel 

      TableViewColumn { role: "name"; width: 240; title: "Name" } 
      TableViewColumn { role: "ipAddress"; width: 240; title: "IP Address" } 
      TableViewColumn { role: "status"; width: 240; title: "Status" } 

      rowDelegate: wallDiscoveryRowDelegate //comment out 
      itemDelegate: wallDiscoveryItemDelegate //comment out 
     } 

     Component { 
      id: wallDiscoveryRowDelegate 
      Rectangle { 
       width: wallDiscoveryTable.width 
       height: 640 
      } 
     } 

     Component { 
      id: wallDiscoveryItemDelegate 
      Text { 
       anchors.verticalCenter: parent.verticalCenter 
       color: styleData.textColor 
       text: styleData.value 
      } 
     } 
    } 
} 

나는 행과 항목 대표 (나는 "// 주석"로 표시 한 선을 설정하는 줄을 주석 경우) 그러면 테이블이 올바르게 렌더링되어 지정한 모델이 옳다는 것을 나타냅니다. 그러나 행 및 항목 대리자를 설정할 때 렌더링 된 테이블의 첫 번째 행만 가져옵니다.

다른 사람이 두 번째 경우 (행 및 항목 대리인 포함)에서 잘못된 점을 지적 할 수 있습니까?

답변

1

대리인이 많습니다. 640 픽셀은 대부분의 화면 높이의 절반 이상입니다. 모델이 존재하지 않기 때문에 코드가 제대로 실행되지 않지만 더미 모델을 사용하여 높이를 100 픽셀로 줄이면 다른 항목이 표시됩니다. 또한 현재 코드를 사용하여 다른 항목을 보려면 아래로 스크롤 할 수 있어야합니다.

+0

네가 맞아! 나는 지금 어리 석다. :피 – balajeerc