在QML - Emulator中呈现ListView项目(Rendering of ListView Items in QML - Emulator)
你好,我有以下简单的QML应用程序:
import QtQuick 1.0 import com.nokia.symbian 1.0 Window { id: window StatusBar { id: statusBar anchors.top: window.top } TabBar { id: tabBar anchors.top: statusBar.bottom TabButton { id: someButton text: "Something" tab: somePage } } TabGroup { id: tabGroup anchors.top: tabBar.bottom anchors.bottom: toolBar.top anchors.left: parent.left anchors.right: parent.right Page { id: somePage ListView { id: someLView anchors.fill: parent model: someModel delegate: Text { text: name color: "white" } } } } ToolBar { id: toolBar anchors.bottom: window.bottom tools: ToolBarLayout { id: toolBarLayout ToolButton { flat: true iconSource: "toolbar-back" onClicked: Qt.quit() } } } ListModel { id: someModel ListElement { name: "Element1" } ListElement { name: "Element2" } ListElement { name: "Element3" } ListElement { name: "Element4" } ListElement { name: "Element5" } ListElement { name: "Element6" } ListElement { name: "Element7" } ListElement { name: "Element8" } ListElement { name: "Element9" } ListElement { name: "Element10" } ListElement { name: "Element11" } ListElement { name: "Element12" } ListElement { name: "Element13" } ListElement { name: "Element14" } ListElement { name: "Element15" } ListElement { name: "Element16" } ListElement { name: "Element17" } ListElement { name: "Element18" } ListElement { name: "Element19" } ListElement { name: "Element20" } ListElement { name: "Element21" } ListElement { name: "Element22" } ListElement { name: "Element23" } } }但是当我尝试在模拟器上运行它时,这是移动列表时的常见行为:
列表的第一行“元素1”通过TabBar甚至通过状态栏呈现 列表中的“Element2”到xxx的后面行被渲染,以便当它们完全渲染到TabBar上时,它们就会消失。 (例如,“元素2”已经不被渲染,但是“元素3”被渲染,因为它不完全覆盖TabBar任何想法为什么会这样? 看到图片:
更新:我补充说
anchors.fill: parent到Page元素,但这并没有解决问题
SOLVED剪辑:true需要添加到ListView
Hello I have the following simple QML app:
import QtQuick 1.0 import com.nokia.symbian 1.0 Window { id: window StatusBar { id: statusBar anchors.top: window.top } TabBar { id: tabBar anchors.top: statusBar.bottom TabButton { id: someButton text: "Something" tab: somePage } } TabGroup { id: tabGroup anchors.top: tabBar.bottom anchors.bottom: toolBar.top anchors.left: parent.left anchors.right: parent.right Page { id: somePage ListView { id: someLView anchors.fill: parent model: someModel delegate: Text { text: name color: "white" } } } } ToolBar { id: toolBar anchors.bottom: window.bottom tools: ToolBarLayout { id: toolBarLayout ToolButton { flat: true iconSource: "toolbar-back" onClicked: Qt.quit() } } } ListModel { id: someModel ListElement { name: "Element1" } ListElement { name: "Element2" } ListElement { name: "Element3" } ListElement { name: "Element4" } ListElement { name: "Element5" } ListElement { name: "Element6" } ListElement { name: "Element7" } ListElement { name: "Element8" } ListElement { name: "Element9" } ListElement { name: "Element10" } ListElement { name: "Element11" } ListElement { name: "Element12" } ListElement { name: "Element13" } ListElement { name: "Element14" } ListElement { name: "Element15" } ListElement { name: "Element16" } ListElement { name: "Element17" } ListElement { name: "Element18" } ListElement { name: "Element19" } ListElement { name: "Element20" } ListElement { name: "Element21" } ListElement { name: "Element22" } ListElement { name: "Element23" } } }But when I try to run this on an Emulator, this is common behavior when moving the list:
First line of the list "Element1" is rendered over the TabBar even over the StatusBar Following lines of the list "Element2" to xxx are rendered so that when they completely render over the TabBar only then they dissapear. (for example "Element2" is already not rendered, but "Element3" is rendered because it is not completely over the TabBarAny ideas of why is this so? See the picture:
Update: I added
anchors.fill: parentto the Page element but this did not solve the problem
SOLVED clip: true needs to be added to ListView
最满意答案
只需添加
clip: true到ListView
Just add
clip: trueto the ListView
更多推荐
发布评论