Signal on TreeView column move
-
Hi.
I have a qml treeview with several column. The user can move the colum ... I do not see any signal that could be intercepted to handle the event.
Everything work fine, but I need to know that the user change the column order.
Thanks for any suggestion. -
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. -
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?