@jeremy_k Unfortunately, my MouseArea that covers the entire view and finds the delegate does not detect row insertion. For example on the picture below two rows surrounded with green were inserted (with beginInsertRows/endInsertRows) and MouseArea stopped responding to the clicks on the last two rows surrounded with red:
alt text
Below I provided the source code of the entire TableView as it is now in my project:
TableView
{
id: table
anchors.fill: parent
columnSpacing: 5
rowSpacing: 3
clip: true
property var columnWidths: [100, 80, 80, 20, 20, 20, 90, 90];
columnWidthProvider: function (column) { return columnWidths[column]; }
property var rowHeight: 40
rowHeightProvider: function (column) { return rowHeight; }
ScrollBar.horizontal: ScrollBar{}
ScrollBar.vertical: ScrollBar{}
ScrollIndicator.horizontal: ScrollIndicator { }
ScrollIndicator.vertical: ScrollIndicator { }
MouseArea
{
//id: ma
anchors.fill: parent
//hoverEnabled: true
onClicked:
{
var index = Math.floor((mouse.y - table.originY) / (table.rowHeight + table.rowSpacing));
console.log("index:", index, " mouse: (", mouse.x, "," , mouse.y, ") table.origin: (", table.originX, ",", table.originY + ") table.content: (", table.contentX, ",", table.contentY + ")")
var item = table.model.rowKey(index)
if (item)
window.openMarket(item)
}
}
QtObject
{
id: enumSymbols
property string spotAllowed: "S"
property string marginAllowed: "M"
property string isolatedMarginAllowed: "I"
}
delegate: DelegateChooser {
role: "type"
DelegateChoice {
roleValue: "symbol"
delegate: SymbolCell { item: model.item }
}
DelegateChoice {
roleValue: "price"
delegate: Text {
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: { var val = model.item[model.name]; return val ? val.toFixed(model.item.pricePrecision) : ""; }
}
}
DelegateChoice {
roleValue: "signal"
delegate: Text {
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: TimeFormat.ago(model.item.signalTime, timeMachine.now)
color: model.item.signalTime ? "black" : "gray"
}
}
DelegateChoice {
roleValue: "enum"
delegate: Text
{
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: model.display ? enumSymbols[model.name] : ""
color: "#1e73cd"
}
}
DelegateChoice {
roleValue: "zparams"
delegate: Text
{
property var zparams: model.item[model.name]
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: zparams ? "(%1, %2, %3)".arg(zparams.lag).arg(zparams.threshold.toFixed(2)).arg(zparams.influence.toFixed(2)) : qsTr("No")
color: zparams ? "black" : "gray"
}
}
DelegateChoice {
roleValue: "check"
delegate: CheckBox {
checked: model.item[model.name];
onClicked: {
table.model.beginUpdateItem(model.item)
model.item[model.name] = checked
table.model.endUpdateItem(model.item)
}
}
}
DelegateChoice {
delegate: Text {
verticalAlignment: Text.AlignVCenter
text: model.item[model.name]
}
}
}
}
If I refresh my TableView with beginResetModel/endResetModel MouseArea starts to work correctly.