C++ (Qt)void MainWindowImpl::dragMoveEvent ( QDragMoveEvent * event ){ if (!(event->mouseButtons() & Qt::LeftButton)) { this->dropEvent(event); event->ignore(); return; }.......................}
void DragWidget::mouseMoveEvent(QMouseEvent *event) { if (!(event->buttons() & Qt::LeftButton)) return; if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance()) return; QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; mimeData->setData(mimeType, data); drag->setMimeData(mimeData); Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); ... }