Drag & drop in a QTableView: which flags do I need in the model?

  • Robert Hairgrove 6 days ago
    The model should not be editable, in the sense that users should not be allowed to type in their own values. But I would like to be able to drag an item from one column into the other. So in the model class, presumably I should NOT set the flag Qt::ItemIsEditable but only Qt::ItemIsDropEnabled, is this correct? Of course, I should implement setData() in my model.

    I also need to ensure that only items from the same row can be dropped into other columns. I assume that I would need to derive a custom class from QAbstractTableView and overload the dragEnterEvent() in order to record which row this was called upon?

  • @hungns35
    This was answered as best it can be in the original question post a week ago. Since you are simply re-pasting that, why do you not at least provide a reference link to it? What was wrong with the answers already given there?

Log in to reply