Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framework. More...
#include <qgraphicssceneevent.h>
Public Member Functions | |
QGraphicsSceneDragDropEvent (Type type=None) | |
~QGraphicsSceneDragDropEvent () | |
Destroys the object. | |
QPointF | pos () const |
Returns the mouse position of the event relative to the view that sent the event. | |
void | setPos (const QPointF &pos) |
QPointF | scenePos () const |
Returns the position of the mouse in scene coordinates. | |
void | setScenePos (const QPointF &pos) |
QPoint | screenPos () const |
Returns the position of the mouse relative to the screen. | |
void | setScreenPos (const QPoint &pos) |
Qt::MouseButtons | buttons () const |
Returns a Qt::MouseButtons value indicating which buttons were pressed on the mouse when this mouse event was generated. | |
void | setButtons (Qt::MouseButtons buttons) |
Qt::KeyboardModifiers | modifiers () const |
Returns the keyboard modifiers that were pressed when the drag and drop event was created. | |
void | setModifiers (Qt::KeyboardModifiers modifiers) |
Qt::DropActions | possibleActions () const |
Returns the possible drop actions that the drag and drop can result in. | |
void | setPossibleActions (Qt::DropActions actions) |
Qt::DropAction | proposedAction () const |
Returns the drop action that is proposed, i.e., preferred. | |
void | setProposedAction (Qt::DropAction action) |
void | acceptProposedAction () |
Sets the proposed action as accepted, i.e, the drop action is set to the proposed action. | |
Qt::DropAction | dropAction () const |
Returns the action that was performed in this drag and drop. | |
void | setDropAction (Qt::DropAction action) |
This function lets the receiver of the drop set the drop action that was performed to action, which should be one of the \l{QGraphicsSceneDragDropEvent::possibleActions()}{possible actions}. | |
QWidget * | source () const |
This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent. | |
void | setSource (QWidget *source) |
const QMimeData * | mimeData () const |
This function returns the MIME data of the event. | |
void | setMimeData (const QMimeData *data) |
Public Member Functions inherited from QGraphicsSceneEvent | |
QGraphicsSceneEvent (Type type) | |
~QGraphicsSceneEvent () | |
Destroys the event. | |
QWidget * | widget () const |
Returns the widget where the event originated, or \nullptr if the event originates from another application. | |
void | setWidget (QWidget *widget) |
quint64 | timestamp () const |
void | setTimestamp (quint64 ts) |
Public Member Functions inherited from QEvent | |
QEvent (Type type) | |
Constructs an event object of type type. | |
virtual | ~QEvent () |
Destroys the event. | |
Type | type () const |
Returns the event type. | |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false . | |
virtual void | setAccepted (bool accepted) |
bool | isAccepted () const |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). | |
bool | isInputEvent () const noexcept |
bool | isPointerEvent () const noexcept |
bool | isSinglePointEvent () const noexcept |
virtual QEvent * | clone () const |
Creates and returns an identical copy of this event. | |
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framework.
\inmodule QtWidgets
QGraphicsView inherits the drag and drop functionality provided by QWidget. When it receives a drag and drop event, it translates it to a QGraphicsSceneDragDropEvent.
QGraphicsSceneDragDropEvent stores events of type GraphicsSceneDragEnter, GraphicsSceneDragLeave, GraphicsSceneDragMove, or GraphicsSceneDrop.
QGraphicsSceneDragDropEvent contains the position of the mouse cursor in both item, scene, and screen coordinates; this can be retrieved with pos(), scenePos(), and screenPos().
The scene sends the event to the first QGraphicsItem under the mouse cursor that accepts drops; a graphics item is set to accept drops with \l{QGraphicsItem::}{setAcceptDrops()}.
Definition at line 222 of file qgraphicssceneevent.h.
Constructs a new QGraphicsSceneDragDropEvent of the specified type. The type can be either QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave, QEvent::GraphicsSceneDragMove, or QEvent::GraphicsSceneDrop.
Definition at line 1371 of file qgraphicssceneevent.cpp.
QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent | ( | ) |
Destroys the object.
Definition at line 1379 of file qgraphicssceneevent.cpp.
void QGraphicsSceneDragDropEvent::acceptProposedAction | ( | ) |
Sets the proposed action as accepted, i.e, the drop action is set to the proposed action.
This is equal to:
When using this function, one should not call accept()
.
Definition at line 1574 of file qgraphicssceneevent.cpp.
Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons | ( | ) | const |
Returns a Qt::MouseButtons value indicating which buttons were pressed on the mouse when this mouse event was generated.
Definition at line 1463 of file qgraphicssceneevent.cpp.
Qt::DropAction QGraphicsSceneDragDropEvent::dropAction | ( | ) | const |
Returns the action that was performed in this drag and drop.
This should be set by the receiver of the drop and is returned by QDrag::exec().
Definition at line 1588 of file qgraphicssceneevent.cpp.
const QMimeData * QGraphicsSceneDragDropEvent::mimeData | ( | ) | const |
This function returns the MIME data of the event.
Definition at line 1634 of file qgraphicssceneevent.cpp.
Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers | ( | ) | const |
Returns the keyboard modifiers that were pressed when the drag and drop event was created.
Definition at line 1488 of file qgraphicssceneevent.cpp.
QPointF QGraphicsSceneDragDropEvent::pos | ( | ) | const |
Returns the mouse position of the event relative to the view that sent the event.
Definition at line 1389 of file qgraphicssceneevent.cpp.
Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions | ( | ) | const |
Returns the possible drop actions that the drag and drop can result in.
Definition at line 1515 of file qgraphicssceneevent.cpp.
Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction | ( | ) | const |
Returns the drop action that is proposed, i.e., preferred.
The action must be one of the possible actions as defined by possibleActions()
.
Definition at line 1542 of file qgraphicssceneevent.cpp.
QPointF QGraphicsSceneDragDropEvent::scenePos | ( | ) | const |
Returns the position of the mouse in scene coordinates.
Definition at line 1415 of file qgraphicssceneevent.cpp.
QPoint QGraphicsSceneDragDropEvent::screenPos | ( | ) | const |
Returns the position of the mouse relative to the screen.
Definition at line 1438 of file qgraphicssceneevent.cpp.
void QGraphicsSceneDragDropEvent::setButtons | ( | Qt::MouseButtons | buttons | ) |
Sets the mouse buttons that were pressed when the event was created to buttons.
Definition at line 1476 of file qgraphicssceneevent.cpp.
void QGraphicsSceneDragDropEvent::setDropAction | ( | Qt::DropAction | action | ) |
This function lets the receiver of the drop set the drop action that was performed to action, which should be one of the \l{QGraphicsSceneDragDropEvent::possibleActions()}{possible actions}.
Call accept()
in stead of acceptProposedAction()
if you use this function.
Definition at line 1604 of file qgraphicssceneevent.cpp.
This function sets the MIME data for the event.
Definition at line 1644 of file qgraphicssceneevent.cpp.
void QGraphicsSceneDragDropEvent::setModifiers | ( | Qt::KeyboardModifiers | modifiers | ) |
Sets the keyboard modifiers that were pressed when the event was created to modifiers.
Definition at line 1502 of file qgraphicssceneevent.cpp.
Sets the position of the mouse to pos; this should be relative to the widget that generated the event, which normally is a QGraphicsView.
Definition at line 1404 of file qgraphicssceneevent.cpp.
void QGraphicsSceneDragDropEvent::setPossibleActions | ( | Qt::DropActions | actions | ) |
Sets the possible drop actions that the drag can result in to actions.
Definition at line 1528 of file qgraphicssceneevent.cpp.
void QGraphicsSceneDragDropEvent::setProposedAction | ( | Qt::DropAction | action | ) |
Sets the proposed action to action. The proposed action is a Qt::DropAction that is one of the possible actions as given by possibleActions()
.
Definition at line 1557 of file qgraphicssceneevent.cpp.
Sets the scene position of the mouse to pos.
Definition at line 1427 of file qgraphicssceneevent.cpp.
Sets the mouse position relative to the screen to pos.
Definition at line 1450 of file qgraphicssceneevent.cpp.
This function set the source widget, i.e., the widget that created the drop event, to source.
Definition at line 1625 of file qgraphicssceneevent.cpp.
QWidget * QGraphicsSceneDragDropEvent::source | ( | ) | const |
This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent.
Definition at line 1614 of file qgraphicssceneevent.cpp.