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。這可能會拯救別人。 –