PDA

View Full Version : Drag&Drop between QTableViews



Babi07
9th November 2012, 15:56
Hi All,
I enabled the Drag & Drop between two QTableViews. I followed the steps in Qt documentation, I implemented the methods in my model:

Qt::ItemFlags flags(const QModelIndex &index) const;
QStringList mimeTypes() const;
QMimeData* mimeData(const QModelIndexList &indexes) const;
Qt::DropAction supportedDropActions();
bool dropMimeData(const QMimeData *data,Qt::DropAction action,int row, int column, const QModelIndex &parent);

and I enabled the drag and drop in both the table views:

ui->pls_tableView->setDragDropOverwriteMode(false);
ui->pls_tableView->setDragEnabled(true);
ui->pls_tableView->setAcceptDrops(true);
ui->pls_tableView->viewport()->setAcceptDrops(true);
ui->pls_tableView->setDropIndicatorShown(true);

The problem is when one of the table is empty: I want to drag a row from a table (with some items) and drop in the other even if this is empty but the dropping in this case doesn't work. It is not allowed. So I can't copy the row from the first table in to the second one.

Anybody knows how can I do?

Thanks