我想隐藏装载加载器的项目。不幸的是,我无法在Loader.item中访问可见的属性。以下代码是我的QML代码。有什么建议吗?非常感谢!
DefaultPage.qml
Rectangle {
id:root
width: 800
height: 600
focus: true
Timer {
id:timeoutTimer
interval: 60000;
running: true;
repeat: true
onTriggered: {
mainWidget.visible=false;
video.opacity = 1;
}
}
Keys.onPressed: {
console.log(pageLoader.item.objectName.toString());
pageLoader.item.mainWidget.visible=true;
videoLoader.item.video.opacity = 0.1;
timeoutTimer.restart();
event.accepted = true;
}
Loader
{
id:videoLoader
source: "VideoPage.qml"
}
Loader
{
id:pageLoader
source:"MainMenuPage.qml"
}
}
VideoPage.qml
Video{
id:video
x: -8
y: -17
width: 800
height: 600
source: "123.mp4"
autoLoad: true
autoPlay: true
}
MainMenuPage.qml
Item{
id:mainWidget
x: 30
y: 100
width: 210
height: 160
visible: true
ListView {
id: mainList
x: 313
y: 120
width: 200
height: 160
currentIndex:1
visible: parent.visible
delegate: Item {
width: 200
height: 40
Column { Text { text: name; font.pointSize: 22; color: "#FFFFFF"} }
}
highlight: Rectangle { color: "lightsteelblue"; radius: 5 ; opacity:0.5}
focus: true
model: ListModel {
ListElement {
name: "Barcode Input"
}
ListElement {
name: "Reset"
}
ListElement {
name: "Engineer Mode"
}
}
}
}
答案 0 :(得分:2)
这是无效的:
videoLoader.item.video.opacity = 0.1;
pageLoader.item.mainWidget.visible=true;
您不需要添加商品id
。请改用:
videoLoader.item.opacity = 0.1;
pageLoader.item.visible=true;