1
在QML我已经实现与SwipeView
这样的简单的应用程序:QML SwipeView具有不透明的背景。我怎样才能让它透明?
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
Window {
visible: true
Rectangle{
id: bg
anchors.fill: parent
color: "red"
}
SwipeView {
id: swipeView
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: tabBar.top
currentIndex: tabBar.currentIndex
Page{
// Empty
}
Page{
Rectangle{
anchors.fill: parent
color:"purple"
}
}
}
TabBar {
id: tabBar
width: parent.width;
height: 30;
anchors.bottom: parent.bottom
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("Empty")
}
TabButton {
text: qsTr("Purple")
}
}
}
如果删除了SwipeView
的红色背景Rectangle
节目,但只要SwipeView
存在时,它要么是白色或紫色取决于显示的页面。
紫页中选择:
空页面中选择:
随着swipeview和TabBar注释掉:
那么,我怎样才能通过使红色背景闪耀(即使SwipeView
透明)?
我发布的是温柔的我问:感谢后想通了这一点只有我自己分钟! –
作为一个说明,我认为Page是强制性的,但如果你喜欢,你可以在它的位置使用Item。这可能会拯救别人。 –