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;
226Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defaultDropAction)
230 qWarning(
"QDrag: No mimedata set before starting the drag");
231 return d->executed_action;
233 Qt::DropAction transformedDefaultDropAction = Qt::IgnoreAction;
235 if (defaultDropAction == Qt::IgnoreAction) {
236 if (supportedActions & Qt::MoveAction) {
237 transformedDefaultDropAction = Qt::MoveAction;
238 }
else if (supportedActions & Qt::CopyAction) {
239 transformedDefaultDropAction = Qt::CopyAction;
240 }
else if (supportedActions & Qt::LinkAction) {
241 transformedDefaultDropAction = Qt::LinkAction;
244 transformedDefaultDropAction = defaultDropAction;
246 d->supported_actions = supportedActions;
247 d->default_action = transformedDefaultDropAction;
248 QPointer<QDrag> self =
this;
249 auto executed_action = QDragManager::self()->drag(self.data());
251 return Qt::IgnoreAction;
252 d->executed_action = executed_action;
253 return d->executed_action;
280QPixmap QDrag::dragCursor(Qt::DropAction action)
const
282 typedef QMap<Qt::DropAction, QPixmap>::const_iterator Iterator;
285 const Iterator it = d->customCursors.constFind(action);
286 if (it != d->customCursors.constEnd())
289 Qt::CursorShape shape = Qt::ForbiddenCursor;
292 shape = Qt::DragMoveCursor;
295 shape = Qt::DragCopyCursor;
298 shape = Qt::DragLinkCursor;
301 shape = Qt::ForbiddenCursor;
303 return QGuiApplicationPrivate::instance()->getPixmapCursor(shape);