Unsolved Signal on TreeView column move
-
Here you go: QHeaderView::sectionMoved().
Further info here: http://doc.qt.io/qt-5/qheaderview.html#moving-header-sections
-
@sierdzio
Thanks for your answer, but unfortunately it cannot solve my problem.
I do not have any QtableWidget, QtableView or QtreeView. I need to handle the signal in the qml module.TreeView {
…
model : myModel
TableViewColumn {
role : "role1"
title : "title1"
movable : true
resizable : true
delegate : Item { …}
}
…
TableViewColumn {
role : "role-n"
title : "title-n"
movable : true
resizable : true
delegate : Item { …}
}
}The application user can move the column as he would like, and I have to save his settings for the next session. But I do not see any way to be notified in the qml module.
Should I redesign my application in order to use a QtreeView ?
Thanks again for any suggestions.
-
Ah, QML, sorry. I assumed we talk about widgets.
In QML I'm not sure... it may well be that this functionality is missing altogether. One possible hint I've found is this: http://doc.qt.io/qt-5/qml-qtquick-controls-treeview.html#headerDelegate-prop Maybe you could use Connections element to react to changes to styleData.column property. I'm not sure if it will work, though.
-
@sierdzio said in Signal on TreeView column move:
column
I didn't fully understad your answer: I know that styleData.column is changed:
Quite easy in development phase ...
headerDelegate: Item {
...
Text { text : styleData.value + " : " + styleData.column}}
)
-
...SORRY: I submit an uncomplete post.
I didn't fully understand your answer: I know that styleData.column is changed: Quite easy in development phase ... headerDelegate: Item { ... Text { text : styleData.value + " : " + styleData.column} .... }
But I'm not able to handle any event. I do not understand your quote about using a Connection ...
-
I was thinking about something like this:
Connection { target: headerDelegate1.styleData.column onColumnChanged: something(); }
But now that I wrote it down I see it won't work, because styleData is an attached property, it won't be available outside of headerDetegate body. So unless you declare signal handling there, inside your
headerDelegate: Item {
(where I'm still very unsure if it will work), my suggestion is not a correct one. -
I didn't find any solution.
So I'm going to disable the user column move and add an extra option panel to allow the user to set up the columns order … quite obsolete, but I can not help it.
Thanks anyway for your comments. -
@Cesario said in Signal on TreeView column move:
I need to handle the signal in the qml module.
You can't, when you move the column the model will have no idea it happened, the view just remaps the indexes internally.
-
So what ?
- The indexes are internally rearranged, so I cannot know anymore the column #3 is that one with role =’role03’;
- I cannot intercept the click on the header (if you define a MouseArea on the headerDelegate you will file to handle any signals!;
- There are no clear signals to handle drop event (you know, the column move is managed internally like a drag/drop area);
No way. Forget about... It should be something wrong in my post: I cannot understand why it is so easy to move around a TableViewColumn and there is no way to handle the event.
-
Looks like a missing feature. Maybe suggest it on https://bugreports.qt.io?