I have a Qt application where I am using a QStandardItemModel derived class, and a QTreeView to interact with it. I would like to enable drag and drop to copy and move items around the model. To enable this, I have done the following:

  • In QStandardItem subclasses that represent leaf nodes: setDragEnabled(true) and override clone() to return a real copy of the item.
  • In QStandardItem subclasses that represent Folder nodes: setDropEnabled(true)
  • In QTreeView: setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true);


Drag and Drop works to the extent that it honors which items can be dragged and which can accept drops. However, whether moving or copying it does not create new items using my clone() functions. It only copies the settings and data available to the QStandardItem base class, losing subclass overrides and such.

How do I get the model and views to make use of my clone() functions, or work around this?

Thank you for any assistance.