【问题标题】:Why is ScrollablePage not recognized in a QTQuick 2/QML page definition?为什么在 QTQuick 2/QML 页面定义中无法识别 ScrollablePage?
【发布时间】:2019-12-20 10:44:07
【问题描述】:

我是 QTQuick 2 和 QML 的新手。 我正在尝试将一个 UI 组合在一起,将一系列页面加载到 stackView 中。 我有以下 qml.page 代码 sn-p 我正在尝试迁移到 QtQuick 2.14。 我从 QTCreator 的示例中得到了这个示例。

import QtQuick 2.4
import QtQuick.Layouts 1.14
import QtQuick.Controls 2.14

ScrollablePage {
    id: page

    Column {
        spacing: 40
        width: parent.width

        Label {
            width: parent.width
            wrapMode: Label.Wrap
            horizontalAlignment: Qt.AlignHCenter
            text: "Some Text"
        }

        ColumnLayout {
            spacing: 20
            anchors.horizontalCenter: parent.horizontalCenter

            Button {
                text: "First"
                Layout.fillWidth: true
            }
            Button {
                id: button
                text: "Second"
                highlighted: true
                Layout.fillWidth: true
            }
            Button {
                text: "Third"
                enabled: false
                Layout.fillWidth: true
            }
        }
    }
}

我正在使用以下代码 sn-p 加载页面:

I get the following error at run time:

delegate: ItemDelegate {
                width: parent.width
                text: model.title
                font.pixelSize: 20
                font.bold: true
                highlighted: ListView.isCurrentItem
                onClicked: {
                    listView.currentIndex = index
                    stackView.push("qrc:/pages/ManageCollections.qml")
                    drawer.close()
                }
            }

qrc:/gallery.qml:180:5: QML StackView: 推送: qrc:/pages/ManageCollections.qml:54 ScrollablePage 不是类型

有人可以帮助阐明这一点和/或让我指出如何解决这个问题的正确方向吗?

谢谢, 约翰B

【问题讨论】:

    标签: qt qml qtquick2


    【解决方案1】:

    好的。所以看起来 ScrollablePage 不是 QtQuick 2.14 中支持的类型;我应该使用 ScrollView。这些 QtQuick 版本之间支持/不推荐使用哪些控件让我感到困惑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-28
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多