2012-03-07 38 views
1

QMLでリストビューをタブに表示させる方法を教えてください。私はN9(Meego)用のアプリケーションでコードを使用しますが、今はSymbianで使用する必要があります。 meegoからsymbianに変換してもリストビューは表示されません。助けてください。 注:タブを使用しないと同じリストビューが表示されます。listviewはTabGroup QMLに表示されませんか?

私のコード:

import QtQuick 1.1 
import com.nokia.symbian 1.1 
import com.nokia.extras 1.1 
import "UIConstants.js" as UiConstants 

Page { 
    id: mainpage 

     orientationLock: PageOrientation.LockPortrait 



    tools: 
    TabBar { 
      // platformStyle: TabButtonStyle { } 
      TabButton { 
      text: "Tab 1" 
       tab: tab1 

      } 
      TabButton { 
       text: "Tab 2" 

       tab: tab2 

      } 
      TabButton { 
       text: "Tab 3" 
       tab: tab3 

      } 
      TabButton { 
       text: "Tab 4" 
       tab: tab4 

      } 
         } 



    TabGroup { 
      id: tabGroup 

      PageStack { 
       id: tab1 
       Component.onCompleted: tab1.push(listPage) 

      // define the content for tab 1 
      Page { 
       id: listPage 


        Item { 
          id: testList 
          anchors.fill: parent 

           function openFile(file) { 
           var component = Qt.createComponent(file) 

           if (component.status == Component.Ready) { 
            mainWindow.pageStack.push(component); 
            console.log("Loading component okay"); 
           } 
           else { 
       console.log("Error loading component:", component.errorString()); 
           } 
          } 

          ListModel { 
           id: pagesModel 

           ListElement { 
            page: "InfoBannerPage.qml" 
            title: "InfoBanner" 
            subtitle: "Info Banner" 
           } 

           ListElement { 
            page: "RatingIndicator.qml" 
            title: "RatingIndicator" 
            subtitle: "Indicates ratings" 
           } 

          } 

          ListView { 
           id: list 
           model: pagesModel 
           anchors.fill: parent 

           delegate: ListItem { 
            id: listItem 

            platformInverted: mainWindow.childrenInverted 

            Row { 
             id: listItemRow 


             Column { 

              ListItemText { 
               id: mainText 
               // width: listItemRow.width 
               role: "Title" 
               text: title 

              } 

              ListItemText { 
               id: subText 
              // width: listItemRow.width 
               role: "SubTitle" 
               text: subtitle 
               visible: text != "" 

              } 
             } 
            } 

            onClicked: { testList.openFile(page); } 
           } // listItem 
          } // listView 

          ScrollDecorator { 
           flickableItem: listPage 
           platformInverted: mainWindow.childrenInverted 
          } 
         } // item 
        } // page 
    } 



      Page { 
       id: tab2 

      } 
      Page { 
       id: tab3 

      } 
      Page { 
      id: tab4 

     } 

    } 

}

答えて

0

あなたのレイアウト機能に問題があります。

1の作業:

import QtQuick 1.1 
import com.nokia.symbian 1.1 
import com.nokia.extras 1.1 

Page { 
    id: mainpage 

     orientationLock: PageOrientation.LockPortrait 



// tools: 
    TabBar { 
     id: tabBar 
     anchors {top: parent.top } 
      // platformStyle: TabButtonStyle { } 
      TabButton { 
      text: "Tab 1" 
       tab: tab1 

      } 
      TabButton { 
       text: "Tab 2" 

       tab: tab2 

      } 
      TabButton { 
       text: "Tab 3" 
       tab: tab3 

      } 
      TabButton { 
       text: "Tab 4" 
       tab: tab4 

      } 
         } 



    TabGroup { 
      id: tabGroup 
      anchors {top: tabBar.bottom; bottom: parent.bottom} 

      PageStack { 
       id: tab1 
       Component.onCompleted: tab1.push(listPage) 

      // define the content for tab 1 
      Page { 
       id: listPage 
       anchors.fill: parent 


        Item { 
          id: testList 
          anchors.fill: parent 

           function openFile(file) { 
           var component = Qt.createComponent(file) 

           if (component.status == Component.Ready) { 
            mainWindow.pageStack.push(component); 
            console.log("Loading component okay"); 
           } 
           else { 
       console.log("Error loading component:", component.errorString()); 
           } 
          } 

          ListModel { 
           id: pagesModel 

           ListElement { 
            page: "InfoBannerPage.qml" 
            title: "InfoBanner" 
            subtitle: "Info Banner" 
           } 

           ListElement { 
            page: "RatingIndicator.qml" 
            title: "RatingIndicator" 
            subtitle: "Indicates ratings" 
           } 

          } 

          ListView { 
           id: list 
           model: pagesModel 
           anchors.fill: parent 

           delegate: ListItem { 
            id: listItem 

//          platformInverted: mainWindow.childrenInverted 

            Row { 
             id: listItemRow 
             anchors.fill: listItem.paddingItem 


             Column { 

              ListItemText { 
               id: mainText 
               // width: listItemRow.width 
               role: "Title" 
               text: title 

              } 

              ListItemText { 
               id: subText 
              // width: listItemRow.width 
               role: "SubTitle" 
               text: subtitle 
               visible: text != "" 

              } 
             } 
            } 

            onClicked: { testList.openFile(page); } 
           } // listItem 
          } // listView 

          ScrollDecorator { 
//         flickableItem: listPage 
//         platformInverted: mainWindow.childrenInverted 
          } 
         } // item 
        } // page 
    } 



      Page { 
       id: tab2 

      } 
      Page { 
       id: tab3 

      } 
      Page { 
      id: tab4 

     } 

    } 
} 
+0

Koyingこんにちは...それは –

+0

を働いているが、新しい問題がある..finallyありがとうございました。それはアイテムがクリック可能ではないようですか?あなたが私を助けて、もし私がすべての項目が画面に表示されない場合、リストをスクロールさせたいのですか? –

関連する問題