Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowsdrag.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWINDOWSDRAG_H
5#define QWINDOWSDRAG_H
6
7#include "qwindowscombase.h"
9
10#include <qpa/qplatformdrag.h>
11#include <QtGui/qpixmap.h>
12#include <QtGui/qdrag.h>
13
14struct IDropTargetHelper;
15
17
18class QPlatformScreen;
19
21public:
23 IDataObject *retrieveDataObject() const override;
24};
25
26class QWindowsOleDropTarget : public QWindowsComBase<IDropTarget>
27{
28public:
30 ~QWindowsOleDropTarget() override;
31
32 // IDropTarget methods
33 STDMETHOD(DragEnter)
34 (LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) override;
35 STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) override;
36 STDMETHOD(DragLeave)() override;
37 STDMETHOD(Drop)
38 (LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) override;
39
40private:
41 void handleDrag(QWindow *window, DWORD grfKeyState, const QPoint &, LPDWORD pdwEffect);
42
43 QWindow *const m_window;
44 QRect m_answerRect;
45 QPoint m_lastPoint;
46 DWORD m_chosenEffect = 0;
47 DWORD m_lastKeyState = 0;
48};
49
51{
52public:
54 virtual ~QWindowsDrag();
55
56 Qt::DropAction drag(QDrag *drag) override;
57
58 static QWindowsDrag *instance();
59 void cancelDrag() override { QWindowsDrag::m_canceled = true; }
60 static bool isCanceled() { return QWindowsDrag::m_canceled; }
61 static bool isDragging() { return QWindowsDrag::m_dragging; }
62
63 IDataObject *dropDataObject() const { return m_dropDataObject; }
64 void setDropDataObject(IDataObject *dataObject) { m_dropDataObject = dataObject; }
67
68 IDropTargetHelper* dropHelper();
69
70private:
71 static bool m_canceled;
72 static bool m_dragging;
73
74 QWindowsDropMimeData m_dropData;
75 IDataObject *m_dropDataObject = nullptr;
76
77 IDropTargetHelper* m_cachedDropTargetHelper = nullptr;
78};
79
81
82#endif // QWINDOWSDRAG_H
\inmodule QtGui
Definition qdrag.h:22
\inmodule QtCore
Definition qmimedata.h:16
The QPlatformDrag class provides an abstraction for drag.
The QPlatformScreen class provides an abstraction for visual displays.
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qwindow.h:63
Windows drag implementation.
static bool isDragging()
IDataObject * dropDataObject() const
virtual ~QWindowsDrag()
static bool isCanceled()
QMimeData * dropData()
Return data for a drop in process.
void setDropDataObject(IDataObject *dataObject)
static QWindowsDrag * instance()
void releaseDropDataObject()
IDropTargetHelper * dropHelper()
May be used to handle extended cursors functionality for drags from outside the app.
Qt::DropAction drag(QDrag *drag) override
void cancelDrag() override
Cancels the currently active drag (only for drags of the current application initiated by QPlatformDr...
Special mime data class for data retrieval from Drag operations.
QWindowsDropMimeData()=default
IDataObject * retrieveDataObject() const override
Implementation of IDropTarget.
~QWindowsOleDropTarget() override
LPDATAOBJECT DWORD grfKeyState
LPDATAOBJECT DWORD POINTL pt
STDMETHOD() DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) override
LPDATAOBJECT pDataObj
STDMETHOD() DragLeave() override
Combined button and popup list for selecting options.
DropAction
GLfloat GLfloat GLfloat w
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]