Drag & Drop event end
-
Hi Folks,
I have a small application, where I'm using QTableView with QStandardItemModel. I enabled the drag & drop whithin the table.
My problem is, that I couldn't find an lightweight, stange-forward way to detect the exact finish of drag & drop, when the model is in the final state, which is visible for the user.Can anybody tell me, how should I catch this?
Regards,
Nobert -
Hi,
I checked your suggestion, and I tried out with the following code:
@
view->horizontalHeader()->setSectionsMovable(true);
view->verticalHeader()->setSectionsMovable(true);connect(view->horizontalHeader(), &QHeaderView::sectionMoved, [this](int, int, int) {qDebug() << "horizontal";}); connect(view->verticalHeader(), &QHeaderView::sectionMoved, [this](int, int, int) {qDebug() << "vertical";});
@
but nothing was happening.
could you provide me some code example, how should I use the headerView?Regards,
Nobertcan Anybody help me?
-
@
QTableView *tableWidget = new QTableView;
QStandardItemModel *itemModel = new QStandardItemModel;
tableWidget->setModel(itemModel);itemModel->setColumnCount(4); itemModel->setRowCount(5); for (int col = 0 ; col < itemModel->columnCount() ; ++col) { for (int row = 0 ; row < itemModel->rowCount() ; ++row) { QStandardItem *item = new QStandardItem(tr("Test %1 %2").arg(col).arg(row)); itemModel->setItem(row, col, item); } } tableWidget->horizontalHeader()->setSectionsMovable(true); tableWidget->verticalHeader()->setSectionsMovable(true);
@
With that you can move rows up and down and columns left to right