Qt 文本过扫,如何修复?
我在ListView中有如下项目:Qt 文本过扫,如何修复?,qt,qml,swipe,Qt,Qml,Swipe,我在ListView中有如下项目: delegate: SwipeDelegate { contentItem: Row { ... } } 我想用刷卡。但当我添加SwipeDelegate时,我得到了以下结果: 如何在文本上创建滑动元素?我尝试使用z属性,但使用z打开时,我的刷卡没有设置动画,无法关闭 这是我的代码: //SomePage.qml: import QtQuick 2.12 import QtQuick.Controls 2.12 Scro
delegate: SwipeDelegate {
contentItem: Row {
...
}
}
我想用刷卡。但当我添加SwipeDelegate时,我得到了以下结果:
如何在文本上创建滑动元素?我尝试使用z
属性,但使用z
打开时,我的刷卡没有设置动画,无法关闭
这是我的代码:
//SomePage.qml:
import QtQuick 2.12
import QtQuick.Controls 2.12
ScrollView {
ListView {
id: someListView
model: SomeItems {}
delegate: SwipeDelegate {
width: someListView.width
Row {
leftPadding: 5
width: parent.width
Image {
id: someImg
height: 38
source: myImage
width: height
}
Column {
leftPadding: 5
width: parent.width - someImg.width - 10
// Name
Text {
id: someName
text: myCount.toString() + " × " + myName
}
// Number
Text {
id: someNumber
text: myNumber.toLocaleString(Qt.locale("ru-RU"), "f", 0)
anchors.right: parent.right
font.pixelSize: 12
rightPadding: 5
}
}
}
swipe.right: Row {
anchors.right: parent.right
height: parent.height
// Delete button
Label {
text: "\ue800"
color: "black"
font.family: fontFontello.name
height: parent.height
padding: 12
verticalAlignment: Label.AlignVCenter
width: this.height
background: Rectangle {
color: "lightblue"
height: parent.height
width: parent.width
MouseArea {
anchors.fill: parent
onClicked: someListView.model.remove(index)
}
}
}
// Hide button
Label {
text: "\ue80a"
color: "black"
font.family: fontFontello.name
height: parent.height
padding: 12
verticalAlignment: Label.AlignVCenter
width: this.height
background: Rectangle {
color: "lightgray"
MouseArea {
anchors.fill: parent
onClicked: {
...
swipe.close()
}
}
}
}
}
}
}
}
问题是您正在将文本/图像添加到默认的
contentItem
之上,而不是添加到其中。如果您将行
添加到内容项
,它看起来是正确的,如下所示:
delegate: SwipeDelegate {
contentItem: Row {
...
}
}
问题是您正在将文本/图像添加到默认的
contentItem
之上,而不是添加到其中。如果您将行
添加到内容项
,它看起来是正确的,如下所示:
delegate: SwipeDelegate {
contentItem: Row {
...
}
}
“如何在文本上创建滑动元素”是什么意思?你想让“100000”消失,还是向左移动?@Amfasis消失更可取。但这并不重要。也可以向左移动。你说的“如何在文本上创建滑动元素”是什么意思?你想让“100000”消失,还是向左移动?@Amfasis消失更可取。但这并不重要。向左移动也可以。哇,太棒了!你完全正确,谢谢你@JarMan!这么简单…哇,太棒了!你完全正确,谢谢你@JarMan!这么简单。。。