Reputation: 683
I have two QTableView which one has 10 rows and the other is empty. I want to drag a row from first table to 2nd table (empty one).
leftTableView->setModel(leftModel);
leftTableView->resizeColumnsToContents();
leftTableView->setDropIndicatorShown(true);
leftTableView->setDragDropMode(QAbstractItemView::DragOnly);
rightTableView->setModel(rightModel);
rightTableView->resizeColumnsToContents();
rightTableView->setDropIndicatorShown(true);
//rightTableView->setAcceptDrops(true);
rightTableView->setDragDropMode(QAbstractItemView::DropOnly);
in rightModel
I have created insertRow
function which does this:
DATA data;
data.hex = "02";
data.name = "Command";
data_list->insert(row, data);
emit layoutChanged();
return true;
Am I doing something totally wrong? and can someone please guide me on how to achieve drag and drop?
Thanks
Upvotes: 1
Views: 2855
Reputation: 1832
There is a very good drag and drop example in QT Demos. You can find these demos is QT source. You can also find them here Drag and Drop Examples.
Upvotes: 1