Не стал выискивать ошибку. Вот пример который работает:
class sResultModelView : public QTableView, QPoint start_pos.
void sResultModelView::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
start_pos = event->pos();
QTableView::mousePressEvent(event);
}
void sResultModelView::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton) {
int distance = (event->pos() - start_pos).manhattanLength();
if (distance >= QApplication::startDragDistance())
startDrag(Qt::CopyAction | Qt::MoveAction);
}
QTableView::mouseMoveEvent(event);
}
void sResultModelView::startDrag(Qt::DropActions supportedActions)
{
if (selectionModel()->currentIndex().isValid()) {
QMimeData *mimeData = new QMimeData;
QByteArray myArray;
QDataStream c_stream(&myArray, QIODevice::WriteOnly);
QString name = "Id row";
c_stream << name;
mimeData->setData("application/search_quick_mime", myArray);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->exec(supportedActions, Qt::CopyAction);
}
}