Force the layout of tableview on data change

This commit is contained in:
2024-11-27 21:25:56 +01:00
parent 77052d8ef7
commit 6b0e8e316f
2 changed files with 24 additions and 26 deletions

View File

@@ -106,7 +106,7 @@ Item {
TableView
{
property var customWidths: [0.2, 0.5, 0.3, 05, 0.2, 0.2]
//property var customWidths: [0.2, 0.5, 0.3, 05, 0.2, 0.2]
property real newWidth: 0
id: testTable
@@ -139,18 +139,19 @@ Item {
// return newWidth
// }
// Timer
// {
// running: true
// interval: 3000
// repeat: true
// onTriggered:
// {
// //testTable.columnWidths[2] = 150
Timer
{
id: redrawTable
running: true
interval: 1
repeat: false
onTriggered:
{
//testTable.columnWidths[2] = 150
//console.log("Timing..")
// testTable.forceLayout();
// }
// }
testTable.forceLayout();
}
}
@@ -158,9 +159,11 @@ Item {
{
required property bool selected
required property bool current
implicitWidth: tableColumn.width / testTable.columns
Layout.fillWidth: true
implicitWidth: testTable.width / testTable.columns
//Layout.fillWidth: true
implicitHeight: 25
//border.color: "yellow"
//border.width: 1
//color: selected? "lightblue": palette.base
color: selected
? addBusinessBtn.palette.highlight //palette.highlight
@@ -170,7 +173,6 @@ Item {
Text
{
//Layout.fillWidth: true
text: model.display
elide: Text.ElideRight
width: parent.width
@@ -202,6 +204,12 @@ Item {
}
}
}
onContentWidthChanged:
{
//console.log("Model changed!!")
redrawTable.start()
}
}

View File

@@ -22,16 +22,6 @@ CUSTOMER_COLUMN_INDEX = \
"gecos": 5
}
CUSTOMER_COLUMN = \
{
0: "userid",
1: "username",
2: "password",
3: "enabled",
4: "roleid",
5: "gecos"
}
class BusinessModel(QAbstractTableModel):
__visible_index = {}
__col_name = ""