PDA

View Full Version : clearSpans() for selected spans



alex333
24th March 2014, 14:23
Hi all!

clearSpans() in QTableView - removes all row and column spans in the table view.
How I can remove only selected spans?

ChrisW67
24th March 2014, 22:14
Does calling setSpan(row, column, 1, 1) on the span you want to remove work?

alex333
26th March 2014, 11:34
Does calling setSpan(row, column, 1, 1) on the span you want to remove work?

Yes, it works...
but if I have selection, I can`t del span by this method (only using 'brute force of loop').
So, I think the best way - just clear all spans and rebuild it again without selected.

ChrisW67
28th March 2014, 03:16
Why are you trying so hard to avoid looping over the cells in the selection, determining which ones are the top-leftmost in spanned cells, and resetting those? It seems your alternate is to iterate the entire to table to find which items are the top-leftmost item in a spanned area, storing those somewhere, clear all spans, then reinstate all the stored spans except those that would fall inside the selection. Perhaps I don't understand.

alex333
28th March 2014, 10:55
Why are you trying so hard

Good question.
This is because I have additional structure storing the spans. I don't need iterate entire table. So, rebuilding - wery simple for me, may be not most efficient, but simple.

ChrisW67
29th March 2014, 07:04
Fair enough. That helps