76QDrag::QDrag(QObject *dragSource)
77 : QObject(*
new QDragPrivate, dragSource)
80 d->source = dragSource;
83 d->hotspot = QPoint(-10, -10);
84 d->executed_action = Qt::IgnoreAction;
85 d->supported_actions = Qt::IgnoreAction;
86 d->default_action = Qt::IgnoreAction;
232Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defaultDropAction)
236 qWarning(
"QDrag: No mimedata set before starting the drag");
237 return d->executed_action;
239 Qt::DropAction transformedDefaultDropAction = Qt::IgnoreAction;
241 if (defaultDropAction == Qt::IgnoreAction) {
242 if (supportedActions & Qt::MoveAction) {
243 transformedDefaultDropAction = Qt::MoveAction;
244 }
else if (supportedActions & Qt::CopyAction) {
245 transformedDefaultDropAction = Qt::CopyAction;
246 }
else if (supportedActions & Qt::LinkAction) {
247 transformedDefaultDropAction = Qt::LinkAction;
250 transformedDefaultDropAction = defaultDropAction;
252 d->supported_actions = supportedActions;
253 d->default_action = transformedDefaultDropAction;
254 QPointer<QDrag> self =
this;
255 auto executed_action = QDragManager::self()->drag(self.data());
257 return Qt::IgnoreAction;
258 d->executed_action = executed_action;
259 return d->executed_action;
286QPixmap QDrag::dragCursor(Qt::DropAction action)
const
288 typedef QMap<Qt::DropAction, QPixmap>::const_iterator Iterator;
291 const Iterator it = d->customCursors.constFind(action);
292 if (it != d->customCursors.constEnd())
295 Qt::CursorShape shape = Qt::ForbiddenCursor;
298 shape = Qt::DragMoveCursor;
301 shape = Qt::DragCopyCursor;
304 shape = Qt::DragLinkCursor;
307 shape = Qt::ForbiddenCursor;
309 return QGuiApplicationPrivate::instance()->getPixmapCursor(shape);