I have in my app a table view called "partsview" which is descended from a QTableView
, this is on the main form. The relevant header code looks like:
class partsiew : public QTableView
{
Q_OBJECT
public:
explicit partsview(QWidget *parent = 0);
public:
QStringList mimeTypes() const;
QMimeData *mimeData(const QModelIndexList &indexes) const;
};
I have also added the following into the constructor of "partsview":
this->setSelectionMode(QAbstractItemView::ExtendedSelection);
this->setDragEnabled(true);
this->setAcceptDrops(true);
this->setDropIndicatorShown(true);
though the last two are probably not needed.
When dragging, I can pick up a row and drag it to a target - a QTreeView
- and I get the appropriate cursor and even a dropMimeData
event is fired on the treeview
.
However, the row and column values in the dropMimeData()
method are always -1 and the two methods in the "partsview" are not called.
I'm guessing that the first error may have something to do with the second. Have I declared the mimeType()
and mimeData()
methods correctly for them to be called during a drag operation.
I have been following this page in the documentation QT4.6 - Using Model/View Classes