drag and drop non-frozen column header to frozen column header
-
I have first three columns frozen and rest columns non frozen. non frozen columns could be swapped and fixed are not allowed to be swapped. there is a problem with third column which is frozen. if the fourth column is dropped into 3rd column, 3rd column is duplicated which shouldnt happen . How to avoid duplicating. non frozen columns swapping works fine
-
Hi and welcome to the forums
so how did you make the frozen ones ?
like this ?
https://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.html
So you have a secondary view ? -
Hi
but how did you make the drag and drop considering this example does not implement it.
I think you might be using default drag and drop which as my make a copy.did you try adjusting the default drop action to Move Action ?

-
There are two parts in this. Say for eg first 3 columns are frozen. these are fixed. Remaining columns say for eg 4 columns(num of non frozen columns varies on every run) are non frozen. These 4 columns can be swapped. I also have horizontal scroll bar for non frozen columns. first 3 columns cannot be dragged. But if the header(QHeaderView) of the 4 col is dropped to 3rd(happens with 3rd column only) then 4th col has col3+col4(duplicated).. How to avoid duplicating.
Col1 Col2 Col3 Col3+col4 Col5When col4 is dropped into col3, it should remain as it is. nothing should change.
I cannot use header->setSectionsMovable(false); as this would make my movable columns fixed. -
There are two parts in this. Say for eg first 3 columns are frozen. these are fixed. Remaining columns say for eg 4 columns(num of non frozen columns varies on every run) are non frozen. These 4 columns can be swapped. I also have horizontal scroll bar for non frozen columns. first 3 columns cannot be dragged. But if the header(QHeaderView) of the 4 col is dropped to 3rd(happens with 3rd column only) then 4th col has col3+col4(duplicated).. How to avoid duplicating.
Col1 Col2 Col3 Col3+col4 Col5When col4 is dropped into col3, it should remain as it is. nothing should change.
I cannot use header->setSectionsMovable(false); as this would make my movable columns fixed.Hi
But what happens when you drop 4 to 3 ?
It then added all items from one col to the existing col?
Like a selection ?
Do you use default drag and drop or did you implement your own ? -
But on dropping 4 to 3 2nd time evrything is becomes fine.
col1 col2 col3 col4 col5.....
I have few connect signals for expanding, collapsing, header click etc.@Shines
HI
Sorry, it's impossible to guess without a minimal example that reproduces this behavior.I tried to change the frozen example to allow header re-arranging but i could not make it
do a drag and drop that way where it would copy new items to the existing column.- But on dropping 4 to 3 2nd time evrything is becomes fine
so second time you do it, all the duplicated are removed and all is good?
I wonder if its just a update bug then.