qt - QML SwipeView 同时显示所有项目
问题描述
当我在SwipeView中添加带有文本的项目时,它向我显示所有项目都在同一个位置,如果我正在寻找预览SwipeView运行良好。
代码:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.3
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
x: 195
y: 133
width: 200
height: 200
interactive: true
currentIndex: 1
clip: ture
Item {
id: hello
Text {
id: test
text: qsTr("Hello")
}
}
Item {
id: bye
Text {
id: qrr
text: qsTr("Bye")
}
}
}
}
解决方案
SwipeView {
id: swipeView
anchors.fill: parent
}
完整代码:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.3
Window {
id: window
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
currentIndex: 1
anchors.fill: parent
Item {
Text {
text: qsTr("Hello")
}
}
Item {
Text {
text: qsTr("Bye")
}
}
}
}
推荐阅读
- asp.net-core - 管理 TagHelper 的范围
- python - 安全的正则表达式从 html 中查找电子邮件
- vb.net - 如何使用管理员权限编写注册表?
- ssl - 让我们加密证书颁发
- vlcj - 带有运行时选项的 MediaList 播放项目
- scala - Scala中的LazyList和List有什么区别?
- odata - 在 OData Web Api 控制器中使用 $expand 的 NullReferenceException
- java - 抛出预期异常后测试响应
- c# - 从每个十进制数中删除字符串中的几个点/逗号
- php - PhpStorm - 如何在文件模板中转义美元符号(php 变量)?