QML-TableView: Center CheckBox in Cell
Unsolved
QML and Qt Quick
-
Hy!
I have some troubles by creating a table view. I want to create a table, wich contains a checkbox, but I have no idea how to center this checkbox in the cell.
TableView { width: parent.width height: parent.height-50 id: alarmTableInt style : TableViewStyle { textColor: pallete.textColor } model: prjCont.model //model: tmodel rowDelegate: Rectangle { id: row height: pallete.table_RowHeight width: parent.width color: styleData.alternate ? pallete.bgColor : pallete.altBgColor border.color: styleData.selected ? pallete.selectedTextColor : row.color border.width: styleData.selected ? 1 : 0 } headerDelegate: Rectangle { height: 25 Text { anchors.fill: parent text: styleData.value renderType: Text.NativeRendering color: pallete.textColor verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } border.width: 1 border.color: pallete.textColor color: pallete.altBgColor } . . . TableViewColumn { id: checkedCol role: "checked" title: "checked" width: 50 delegate: CheckBox { anchors.fill: parent checked: styleData.value enabled: true onClicked: { var srcIndex = prjCont.model.mapToSource(prjCont.model.index(styleData.row,0)); prjCont.model.getEntry(srcIndex.row).checked = !prjCont.model.getEntry(styleData.row).checked; console.debug("row in Table " + styleData.row + " mapToSource " + srcIndex.row ); console.debug("-got: " + prjCont.model.getEntry(srcIndex.row).checked); } } }
maybe someone has an idea how to center "checked" in the cell.
best regards
Harry -
Hy!
I have some troubles by creating a table view. I want to create a table, wich contains a checkbox, but I have no idea how to center this checkbox in the cell.
TableView { width: parent.width height: parent.height-50 id: alarmTableInt style : TableViewStyle { textColor: pallete.textColor } model: prjCont.model //model: tmodel rowDelegate: Rectangle { id: row height: pallete.table_RowHeight width: parent.width color: styleData.alternate ? pallete.bgColor : pallete.altBgColor border.color: styleData.selected ? pallete.selectedTextColor : row.color border.width: styleData.selected ? 1 : 0 } headerDelegate: Rectangle { height: 25 Text { anchors.fill: parent text: styleData.value renderType: Text.NativeRendering color: pallete.textColor verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } border.width: 1 border.color: pallete.textColor color: pallete.altBgColor } . . . TableViewColumn { id: checkedCol role: "checked" title: "checked" width: 50 delegate: CheckBox { anchors.fill: parent checked: styleData.value enabled: true onClicked: { var srcIndex = prjCont.model.mapToSource(prjCont.model.index(styleData.row,0)); prjCont.model.getEntry(srcIndex.row).checked = !prjCont.model.getEntry(styleData.row).checked; console.debug("row in Table " + styleData.row + " mapToSource " + srcIndex.row ); console.debug("-got: " + prjCont.model.getEntry(srcIndex.row).checked); } } }
maybe someone has an idea how to center "checked" in the cell.
best regards
Harry