小编Man*_*elH的帖子

Qt QML ListView contentHeight行为

将QML ListView元素与其section属性结合使用时,我遇到了一个非常具体的问题.

我使用的是Qt 4.8.6,但是当我在Qt 5.3.1中尝试这个时,我也有同样的问题.

通过简单地将import语句更改为,也可以在旧版本的Qt中运行以下代码

导入QtQuick 1.0(<Qt 4.7.4)

要么

import QtQuick 1.1(For = = Qt 4.7.4)

这是一个独立的用例来演示我的问题:

import QtQuick 2.2

Rectangle {
    width: 800
    height: 800
    color: "black"

    property int pageNumber: 1
    property int totalPages: Math.ceil(animalListView.contentHeight/animalListView.height)

    Text {
        x: 2
        y: 90
        color: "Orange"
        text: "Expected height: " + (animalListView.count*70 + (50*10))
        font.pixelSize: 28
    }

    Text {
        x: 2
        y: 0
        color: "Orange"
        text: "Actual ContentHeight: " + animalListView.contentHeight
        font.pixelSize: 28
    }

    Text {
        x: 2
        y: 30
        color: …
Run Code Online (Sandbox Code Playgroud)

qt listview qt4 qml qt5

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

listview ×1

qml ×1

qt ×1

qt4 ×1

qt5 ×1