Important: Please read the Qt Code of Conduct -

QTableView Multiple Editing Cell

  • Dear All:

    I am trying to create a QTableView where I use a Costumer model and all that is working perfect. Nonetheless I have an small problem. I would like to be able to edit multiple cell at the same time. This mean that if for example I have a Table of 3 x 3 and I select two elements of column 2 and I change one of this values then I change all of the selected one.

    I think I have a way to do this by listen the dataChanged slot but I have a problem here. As soon as I have double click one of the cell to be able to change it I loose the selection. So the question is how I can do to be able to double click in a cell without loosing the selections?

    All the best

  • Hi,

    I'd suggest that you keep the selected cells by reimplementing selectionChanged() and using selectedIndexes() so that you know which cells to update when the users edits one of them.

  • The problem, I guess, would be distinguishing between the multiple-cell select the user makes, and the single-cell select that is made when you double-click.

  • Hi Andre:

    Thanks is exactly my problem how I can make the difference between the single click and the double click. It look like that when I double click Qt call the single click in any case and thus why the selection is gone. Any suggestions?

    All the best

  • The only thing I can think of, is using the time difference between the select action and the double click to determine if it a real selection or the start of an exit action. If the selection is followed by an edit action in the timespace of the double-click interval, I think you should revert to the selection you had before the sequence started.

  • Thanks very much I will try that one it sound as a good idea.


Log in to reply