1
如何使QML中的listview出现在选项卡中。我在N9(Meego)的应用程序中使用代码,但现在我需要在Symbian中使用它。当我将它从meego转换为symbian时,我做了一些更改,但没有出现listview。请任何帮助。 注意:当我不使用标签时出现相同的列表视图!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
}
}
}
喜Koying ......非常感谢你..finally它的工作 – 2012-03-09 07:03:09
但有一个新的问题。似乎该项目不可点击?你能否帮助我,如果我想让列表滚动,如果所有的项目没有出现在屏幕上? – 2012-03-09 07:23:26