How to make a TableView static
-
I am having some trouble making a 'TableView' static. I have already set:
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff selectionMode: SelectionMode.NoSelection
yet you can still scroll in the view. Is there a way to prevent the user from being able to interact with a
TableView
?Note: Also the
TableViewColumn
resizable
andmoveable
properties have been set to false. -
Tried
flickableItem.interactive: false
but I am still able to scroll through the TableView. I imagine this has something to do with the fact that the view doesn't have a static height property set. I tried setting one:height: contentItem.childrenRect.height
which does prevent the table from being scroll-able but that gives me a recursive binding error:
"QML TableView: Binding loop detected for property "height"
-
Just set interactive: false. Its a property of the TableView. You can do a delayed binding by doing the Binding {} item. That might help with the binding loop.
-
Hi,
Do you mean you want to disable it ?
-
@SGaist It's all a bit hard to explain what I want and why but I will try. Essentially, I only want my header text to be visible:
headerDelegate: Rectangle { color: "transparent" implicitHeight: _headerTxt.paintedHeight anchors.margins: 10 Text { id: _headerTxt font: fontStyle.font color: fontStyle.color text: styleData.value } }
however, this was causing an issue with overlapping text in the header:
So I thought if I could make the view static s/t the user can not scroll through it and then determine the height of the view at runtime then problem solved. This required me to set the height:
TableView { id: _sectionDetails anchors.margins: 10 width: parent.width height: contentItem.childrenRect.height ...
but that caused a property binding error. So now I am trying to figure out how to use a delayed binding s/t I do not get the error but even if that works the view still seems scroll-able... (or maybe not scroll-able but more like flick-able) even with a static height value set and:
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff selectionMode: SelectionMode.NoSelection flickableItem.interactive: false
also the TableView columns themselves have their
resizable
andmoveable
properties set to false. -
You know what would solve my problem. If I could somehow make the width of the header be dependent upon the number of columns so that it's not twice as long as seen here:
it may need to be that long when their are more columns coming in from the model but when theirs only two it shouldn't take up the whole page.