Qt, model-view-controller, best delegate



  • Did QTableView and derivated from QAbstractTableModel.

    In the model, several poles are bool. I'd like to edit them (plate) with a click (or double click) on the relevant cell.

    I don't know how I'm not gonna make any editors, but right at the Delegate:createEditor() make setModelData().



  • The delegate ' s essence is in the delegation of editing rights to the model. If a delegate is used and a change in the cell is supported, the appropriate editor must be established.

    In some cases, for example, when using switches, this may appear redundant, but it is often important to allow for the removal of the user ' s body movements so that the model of erratic tiles is not disturbed at all.

    If the challenge is to go on its own way, different from the commonly accepted, and to change the values in the clicking cells, it is likely that it is better not to use delegates at all.

    Reclassify in the heir. QTableView Mice events or signals QItemSelectionModelwhich is available QAbstractItemView::selectionModel()♪ And then, on the basis of the input data on the cell in which the mouse click was made, change the data in the model.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2