我正在开发一个基于QML的应用程序。在那里我动态加载内容。然而,当运行应用程序时,它需要相当长的时间(5-10秒),所以我需要显示任何加载屏幕或指示器,而整个内容正在加载。有没有人能建议我怎么做?例如,在我登录我的应用程序后,加载下一个页面需要一些时间,所以在这段时间内,我希望显示加载屏幕。
App {
id: app
height: 400
width: 200
Rectangle {
id: rectangle
Button {
id: button
text: qsTr("GO TO NEXT PAGE")
onClicked:stackView.push("page2.qml")
}
Image {
id: image
fillMode: Image.PreserveAspectFit
source: "default-app.png"
}
}}假设这是我的代码,那么我可以在哪里使用loader?我以前从来没用过
发布于 2020-09-03 20:41:38
您可以从Loader组件使用status (我猜您之所以使用它,是因为您是“动态”加载的)。然后在BusyIndicator中使用它。
Loader {
id: loader
asynchronous: true
...
BusyIndicator {
anchors.centerIn: parent
running: loader.status == Loader.Loading
}
}见鬼,Qt docs for BusyIndicator应该已经让你开始行动了!
https://stackoverflow.com/questions/63723738
复制相似问题