【发布时间】:2017-10-31 05:34:22
【问题描述】:
我正在我的应用程序中实现 stackview。
main.qml
ApplicationWindow {
id: window
width: 360
height: 520
visible: true
title: "City Explorer"
color:"#FAF7F7"
Loader {
id: splashLoader
anchors.fill: parent
source: "../AppFooter.qml"
visible: true
}
footer: TabBar {
id: appfooter
currentIndex: 0
background: Rectangle {
color: "#d6d6d6"
}
TabButton {
id: control1
background: Rectangle {
width: 44
height: 40
border.color: "#000000"
color: "#d6d6d6"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.Bottom
Image {
id: contentImage
fillMode: Image.PreserveAspectFit
}
}
onClicked: {
contentImage.source = "../images/dashboard_active.png"
contentImage1.source = "../images/settings_inactive.png"
}
}
TabButton {
id: control2
background: Rectangle {
width: 44
height: 40
color: "#d6d6d6"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Image {
id: contentImage1
fillMode: Image.PreserveAspectFit
}
}
onClicked: {
contentImage.source = "../images/dashboard_inactive.png"
contentImage1.source = "../images/settings_active.png"
contentImage2.source = "../images/bookings_inactive.png"
}
}
}
header: ToolBar {
id:appheader
visible: false
RowLayout {
spacing: 20
anchors.fill: parent
ToolButton {
id:backButton
visible: false
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: stackView.depth > 1 ? "../images/back.png" : ""
}
onClicked: {
if (stackView.depth > 1) {
stackView.pop()
} else {
}
}
}
Label {
id: titleLabel
text: "City Explorer"
font.pixelSize: 20
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
}
}
StackView {
id: stackView
initialItem: Pane {
id: pane
}
}
}
SightListViewForm.ui.qml
Item {
width: 360
height: 520
property alias mouseArea: mouseArea
MouseArea {
id: mouseArea
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.fill: parent
Rectangle {
id: rectangle
x: 38
y: 21
width: 200
height: 200
color: "#e03636"
Label {
id: label
x: 61
y: 150
width: 154
height: 28
text: qsTr("Overlapping view")
z: 2
}
}
}
}
SettingsForm.ui.qml
Item {
width: 400
height: 400
Image {
id: image
x: 101
y: 85
width: 150
height: 162
source: "images/singapore.png"
Label {
id: label
x: 8
y: 100
width: 142
height: 23
text: qsTr("Label")
}
}
}
AppFotter.qml
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: showfooter.currentIndex
DashboardListView{
id:dashboard
}
Settings{
id:setting
}
}
DashBoardListViewForm.ui.qml
Item {
id: item1
width: 360
height: 520
property alias button: button
visible: true
Button {
id: button
x: 130
y: 287
text: qsTr("Button")
onClicked: {
console.log("SightListView.qml")
stackview.push("SightListView.qml")
}
}
}
在最初加载视图时按下按钮,它会调用加载 SightListViewForm 的 stackview.push,然后当我按下页脚的设置图标时,我的设置视图将位于 SightListViewForm 后面。 如何更改 Stackview 或 Swipeview 的这种行为,或者我缺少应该添加的内容。这个我不是很清楚。
【问题讨论】:
-
请扩展您的示例,以便说明您的问题。还要确保您的示例代码是正确的。例如。
SwipeView没有属性Anchors。另外请详细说明您想要的行为是什么。考虑换行以使您的文本可读。 -
@derM 我编辑了我的问题
-
请阅读,minimal, complete and verifiable example - 尝试仅构建您的示例标准组件,或提供非标准示例的简单实现,以便我们可以复制并粘贴 QtCreator 中的所有内容并运行它。一个简单工作代码解释了1000多个follow-me-around-vlog。
-
@derM 请检查我用相关代码和图像更新的问题
标签: qt qml swipeview stackview