table view click will "deselect others" when user clicks pre-selected row?
is there any way to turn that OFF?
eg: if i have "row selection" turned on
and i have multiple rows selected
and i click in a row that is already selected...
i want it to NOT deselect other selected rows. i want to intervene and do my own thing...
is there a simple way to override that?
MultiSelectionmode could work for you, but I guess that's not 100% what you expect.
Do you have your own, custom
TableViewalready? Then you could easily implement this behavior and trigger it with selectionChanged signal or simply override
I guess intercepting the click works better for you.
(but then you have to find a solution how to deselect rows again)
yes i have a custom tableView.
no, multiSelection mode doesn't help: it's default behavior is to deselect all the rows you didn't click on.
selectionChanged()won't work because by that time the selection has already changed, it's too late.
you suggest intercepting the click, but that method is not marked virtual, so you can't override it.
you can't override it
But since it's a signal, you can react on that :)
I'm not 100% familiar with the exact order of events (when the selection actually changes), but doing something with
QAbstractItemView::mousePressEventmight also work.
Block the further processing when the selection of the other rows is about to change and replace it with your own, wanted behavior.
I just played around with a standard
QTableWidgeta bit... Have you tried to press and hold
Shiftwhile clicking your selected row? I should not touch the current selection. At least in my test, the selected and clicked row stays selected as well as other items or rows that were selected before...
you suggest holding the shift key while selecting, but that's asking the user to change their behavior (change the spec), rather than coding the app to conform to the spec. the spec is that selection doesn't change when you click a row that is already selected (similar to what happens when you do a drag-and-drop). yes it doesn't change on mouse down: good. but it also MUST NOT change on mouse up.
Pl45m4 last edited by
you suggest holding the shift key while selecting, but that's asking the user to change their behavior
No, I was talking about the "final" click onto that row, that is already seleted to "do your own thing" afterwards. The normal selection can be done as usual without holding any key.
ather than coding the app to conform to the spec
If you change your selection behavior on the app side, you need to find a way how to deselect rows again, which will not work the normal way anymore.
Then, I would say, the
mousePressEventis the way to go... as long as nobody here got a better idea :)
i'm not sure i follow your example about the "final click"?
can you pseudocode that?
the spec is: if you want to "Deselect All", use the Edit menu command, or click on an unselected row (which deselects all other rows), then cmd/ctrl click that row again to deselect it.
can you pseudocode that?
There is no code :) As I said, I was playing around a bit. I used the Shift key while clicking on selected rows and other rows stayed selected. But I dont know how it will impact the rest of your code, if you click while holding Shift (in addition, it's not very intuitive).
So I can't deliver you THE optimal solution (and I dont know, if anybody has done something similar before). These were thoughts how I would do it or where I would start :)
yes it doesn't change on mouse down: good. but it also MUST NOT change on mouse up
clickedsignal gets triggered on