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 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 property real newWidth: 0
id: testTable id: testTable
@@ -139,18 +139,19 @@ Item {
// return newWidth // return newWidth
// } // }
// Timer Timer
// { {
// running: true id: redrawTable
// interval: 3000 running: true
// repeat: true interval: 1
// onTriggered: repeat: false
// { onTriggered:
// //testTable.columnWidths[2] = 150 {
// console.log("Timing..") //testTable.columnWidths[2] = 150
// testTable.forceLayout(); //console.log("Timing..")
// } testTable.forceLayout();
// } }
}
@@ -158,9 +159,11 @@ Item {
{ {
required property bool selected required property bool selected
required property bool current required property bool current
implicitWidth: tableColumn.width / testTable.columns implicitWidth: testTable.width / testTable.columns
Layout.fillWidth: true //Layout.fillWidth: true
implicitHeight: 25 implicitHeight: 25
//border.color: "yellow"
//border.width: 1
//color: selected? "lightblue": palette.base //color: selected? "lightblue": palette.base
color: selected color: selected
? addBusinessBtn.palette.highlight //palette.highlight ? addBusinessBtn.palette.highlight //palette.highlight
@@ -170,7 +173,6 @@ Item {
Text Text
{ {
//Layout.fillWidth: true
text: model.display text: model.display
elide: Text.ElideRight elide: Text.ElideRight
width: parent.width 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 "gecos": 5
} }
CUSTOMER_COLUMN = \
{
0: "userid",
1: "username",
2: "password",
3: "enabled",
4: "roleid",
5: "gecos"
}
class BusinessModel(QAbstractTableModel): class BusinessModel(QAbstractTableModel):
__visible_index = {} __visible_index = {}
__col_name = "" __col_name = ""