Qt 6.11 is out! See what's new in the release
blog
Problem with DoubleSpinBox in TableView
-
Hi,
I'm using Qt 6.11.1, and wanted to use DoubleSpinBox as a table view edit delegate. The values are changed if I use spins.
However, if I manually change the number, say from 4 to 10, and hit enter, or tab, then nothing happens.
Interestingly, in onCommit slot, thecontentItem.textdisplays the value I had put in the spin box, while thevalueis not modified.
The code in question is shown below.
Am I doing something wrong or there is a bug?
best regards,
fantazimport QtQuick import QtQuick.Controls import Qt.labs.qmlmodels Window { width: 640 height: 480 visible: true title: qsTr("TableView with DoubleSpinBox") TableModel { id: myTableModel TableModelColumn { display: "pt_x" } TableModelColumn { display: "pt_y" } rows: [ { pt_x: 0., pt_y: 0. }, { pt_x: 1., pt_y: 8. }, { pt_x: 2., pt_y: 4. }, { pt_x: 3., pt_y: 6. } ] } TableView { anchors.fill: parent model: myTableModel delegate: TableViewDelegate { id: tableCell clip: true implicitWidth: 100 background: Rectangle{anchors.fill: parent; border.color: "darkgray"} contentItem: Text { text: model.display font.pixelSize: 16 } TableView.editDelegate: DoubleSpinBox { width: parent.width; height: parent.height anchors.centerIn: parent value: display from: -10; to: 30 stepSize: 1 editable: true TableView.onCommit: { console.log(`onCommit: content: ${contentItem.text}, value: ${value}`) model.display = value } onValueChanged: { console.log(`onValueChanged: content: ${contentItem.text}, value: ${value}`) } onValueModified: { console.log(`onValueModified: content: ${contentItem.text}, value: ${value}`) } } } } }