QMLとTableViewコンポーネントを使用して、テキストボックスを編集して基になるモデルを更新したいところです。私の問題は、行が視覚的にTableViewから完全に消え、いくつかのクリック後に再び表示されることがあるということです。これは、ランダムに、おそらく行テキストの下をクリックすると発生するようです。QMLで編集しようとするとTableViewの行が消える
私の実装は次のとおりです。
import QtQuick 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.0
import QtQuick.Window 2.1
Window {
visible: true
width: 538
height: 360
ListModel {
id: mymodel
ListElement {
title: "VideoName"
filesize: "1.5GB"
length: "20:00"
}
ListElement {
title: "VideoName"
filesize: "1.5GB"
length: "20:00"
}
ListElement {
title: "VideoName"
filesize: "1.5GB"
length: "20:00"
}
}
ControlView {
visible: true
width: parent.width; height: parent.height
anchors.centerIn: parent
TableView {
width: parent.width; height: parent.height
anchors.centerIn: parent
TableViewColumn {
resizable: false
role: "title"
title: "Title"
width: 250
}
TableViewColumn {
role: "filesize"
title: "Size"
width: 100
resizable: false
}
TableViewColumn {
role: "length"
title: "Length"
width: 100
resizable: false
}
model: mymodel
rowDelegate: Rectangle {
height: 54
}
itemDelegate: RowLayout {
anchors.fill: parent
Loader{
id: loaderEditor
sourceComponent: editor
Connections {
target: loaderEditor.item
}
Component {
id: editor
TextInput {
id: textinput
color: styleData.textColor
text: styleData.value
onEditingFinished: {
mymodel.setProperty(styleData.row, styleData.role,
loaderEditor.item.text)
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
textinput.forceActiveFocus()
textinput.selectAll()
}
}
}
}
}
}
}
}
}
私の問題を強調するために、これはテーブルが最初に表示される方法である:
私がしようと列を編集することができますが、私がクリックした場合その行は行なわれますが、テキスト上には直接表示されません。
あなたは、その行が消えているのを見ることができます。一度クリックすると戻ってくることがありますが、何が原因かわかりません。