【发布时间】:2020-01-12 08:31:46
【问题描述】:
我正在尝试在 TableView 中设计一个带有组合框的移动应用程序。
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.2
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6
import QtQuick.Controls.Styles 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Scroll")
Component.onCompleted: {
var i=0;
for(;i<50;i++)
{
console.log("ApplicationWindow.onCompleted");
var myBoject = {"text":"Banana"};
idListModelForFlightToExport.append(myBoject);
}
}
ListModel {
id: idListModelForFlightToExport
}
Component {
id: checkBoxDelegate
ComboBox {
anchors.fill: parent;
model: [ {"text":"Banana"}, {"text":"Apple"}, {"text":"Coconut"} ]
textRole: "text";
Component.onCompleted: {
console.log("checkBoxDelegate.onCompleted");
}
}
}
TableView {
id: idTableViewFlightsToExport
sortIndicatorVisible: false
model: idListModelForFlightToExport
anchors.fill: parent
TableViewColumn {
id: isExportedColumn
title: qsTr("Column")
movable: false
resizable: false
delegate:checkBoxDelegate
}
}
}
但是当我更改组合框的值,然后向下滚动时,其他一些组合框会更改它们的值。
即,如果我更改第一个组合并滚动,第一个组合的值将显示在另一个组合上(似乎是随机选择的),并且第一个组合似乎被重置。如果我再次滚动,另一个组合会改变值。
【问题讨论】: