【发布时间】: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
【问题讨论】: