Qt 4.8
|
The QDropEvent class provides an event which is sent when a drag and drop action is completed. More...
#include <qevent.h>
Public Functions | |
void | acceptProposedAction () |
Sets the drop action to be the proposed action. More... | |
Qt::DropAction | dropAction () const |
Returns the action to be performed on the data by the target. More... | |
QByteArray | encodedData (const char *) const |
Returns a byte array containing the drag's data, in format. More... | |
const char * | format (int n=0) const |
Returns a string describing one of the available data types for this drag. More... | |
Qt::KeyboardModifiers | keyboardModifiers () const |
Returns the modifier keys that are pressed. More... | |
const QMimeData * | mimeData () const |
Returns the data that was dropped on the widget and its associated MIME type information. More... | |
Qt::MouseButtons | mouseButtons () const |
Returns the mouse buttons that are pressed. More... | |
const QPoint & | pos () const |
Returns the position where the drop was made. More... | |
Qt::DropActions | possibleActions () const |
Returns an OR-combination of possible drop actions. More... | |
Qt::DropAction | proposedAction () const |
Returns the proposed drop action. More... | |
bool | provides (const char *) const |
Returns true if this event provides format mimeType; otherwise returns false. More... | |
QDropEvent (const QPoint &pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type=Drop) | |
Constructs a drop event of a certain type corresponding to a drop at the point specified by pos in the destination widget's coordinate system. More... | |
void | setDropAction (Qt::DropAction action) |
Sets the action to be performed on the data by the target. More... | |
QWidget * | source () const |
If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns 0. More... | |
~QDropEvent () | |
Public Functions inherited from QEvent | |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More... | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More... | |
bool | isAccepted () const |
QEvent (Type type) | |
Contructs an event object of type type. More... | |
void | setAccepted (bool accepted) |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false. More... | |
Type | type () const |
Returns the event type. More... | |
virtual | ~QEvent () |
Destroys the event. More... | |
Public Functions inherited from QMimeSource | |
virtual | ~QMimeSource () |
Destroys the MIME source. More... | |
Protected Variables | |
Qt::DropActions | act |
Qt::DropAction | default_action |
Qt::DropAction | drop_action |
QList< QByteArray > | fmts |
const QMimeData * | mdata |
Qt::KeyboardModifiers | modState |
Qt::MouseButtons | mouseState |
QPoint | p |
Protected Variables inherited from QEvent | |
QEventPrivate * | d |
ushort | t |
Friends | |
class | QApplication |
The QDropEvent class provides an event which is sent when a drag and drop action is completed.
When a widget accepts drop events, it will receive this event if it has accepted the most recent QDragEnterEvent or QDragMoveEvent sent to it.
The drop event contains a proposed action, available from proposedAction(), for the widget to either accept or ignore. If the action can be handled by the widget, you should call the acceptProposedAction() function. Since the proposed action can be a combination of Qt::DropAction values, it may be useful to either select one of these values as a default action or ask the user to select their preferred action.
If the proposed drop action is not suitable, perhaps because your custom widget does not support that action, you can replace it with any of the possible drop actions by calling setDropAction() with your preferred action. If you set a value that is not present in the bitwise OR combination of values returned by possibleActions(), the default copy action will be used. Once a replacement drop action has been set, call accept() instead of acceptProposedAction() to complete the drop operation.
The mimeData() function provides the data dropped on the widget in a QMimeData object. This contains information about the MIME type of the data in addition to the data itself.
QDropEvent::QDropEvent | ( | const QPoint & | pos, |
Qt::DropActions | actions, | ||
const QMimeData * | data, | ||
Qt::MouseButtons | buttons, | ||
Qt::KeyboardModifiers | modifiers, | ||
Type | type = Drop |
||
) |
Constructs a drop event of a certain type corresponding to a drop at the point specified by pos in the destination widget's coordinate system.
The actions indicate which types of drag and drop operation can be performed, and the drag data is stored as MIME-encoded data in data.
The states of the mouse buttons and keyboard modifiers at the time of the drop are specified by buttons and modifiers.
Definition at line 2645 of file qevent.cpp.
QDropEvent::~QDropEvent | ( | ) |
Definition at line 2657 of file qevent.cpp.
|
inline |
Sets the drop action to be the proposed action.
Definition at line 492 of file qevent.h.
Referenced by QLineEdit::dragMoveEvent(), QLineEdit::dropEvent(), and QTextControl::processEvent().
|
inline |
Returns the action to be performed on the data by the target.
This may be different from the action supplied in proposedAction() if you have called setDropAction() to explicitly choose a drop action.
Definition at line 494 of file qevent.h.
Referenced by QAbstractItemViewPrivate::canDecode(), QOleDropTarget::DragOver(), QOleDropTarget::Drop(), QLineEdit::dropEvent(), handle_xdnd_position(), QX11Data::motifdndHandle(), QGraphicsViewPrivate::populateSceneDragDropEvent(), QTextControl::processEvent(), QOleDropTarget::sendDragEnterEvent(), and QX11Data::xdndHandleDrop().
|
virtual |
Returns a byte array containing the drag's data, in format.
data() normally needs to get the data from the drag source, which is potentially very slow, so it's advisable to call this function only if you're sure that you will need the data in that particular format.
The resulting data will have a size of 0 if the format was not available.
Implements QMimeSource.
Definition at line 2679 of file qevent.cpp.
|
virtual |
Returns a string describing one of the available data types for this drag.
Common examples are "text/plain" and "image/gif". If n is less than zero or greater than the number of available data types, format() returns 0.
This function is provided mainly for debugging. Most drop targets will use provides().
Implements QMimeSource.
Definition at line 2700 of file qevent.cpp.
|
inline |
Returns the modifier keys that are pressed.
Definition at line 488 of file qevent.h.
Referenced by QOleDropTarget::DragOver(), QApplication::notify(), and QGraphicsViewPrivate::populateSceneDragDropEvent().
|
inline |
Returns the data that was dropped on the widget and its associated MIME type information.
Definition at line 498 of file qevent.h.
Referenced by QAbstractItemViewPrivate::canDecode(), QUrlModel::canDrop(), QColorWell::dragEnterEvent(), QColorShowLabel::dragEnterEvent(), QLineEdit::dragMoveEvent(), QColorWell::dragMoveEvent(), QLineEdit::dropEvent(), QAbstractItemView::dropEvent(), QColorWell::dropEvent(), QColorShowLabel::dropEvent(), QApplication::notify(), QGraphicsViewPrivate::populateSceneDragDropEvent(), and QTextControl::processEvent().
|
inline |
Returns the mouse buttons that are pressed.
Definition at line 487 of file qevent.h.
Referenced by QApplication::notify(), and QGraphicsViewPrivate::populateSceneDragDropEvent().
|
inline |
Returns the position where the drop was made.
Definition at line 486 of file qevent.h.
Referenced by QLineEdit::dragMoveEvent(), QListModeViewBase::dragMoveEvent(), QPlainTextEdit::dragMoveEvent(), QTextEdit::dragMoveEvent(), QAbstractItemView::dragMoveEvent(), QColorWell::dragMoveEvent(), QLineEdit::dropEvent(), QColorWell::dropEvent(), QAbstractItemViewPrivate::dropOn(), QListModeViewBase::dropOn(), QIconModeViewBase::filterDragMoveEvent(), QIconModeViewBase::filterDropEvent(), QApplication::notify(), QGraphicsViewPrivate::populateSceneDragDropEvent(), and QTextControl::processEvent().
|
inline |
Returns an OR-combination of possible drop actions.
Definition at line 490 of file qevent.h.
Referenced by QApplication::notify(), and QGraphicsViewPrivate::populateSceneDragDropEvent().
|
inline |
Returns the proposed drop action.
Definition at line 491 of file qevent.h.
Referenced by QGraphicsViewPrivate::populateSceneDragDropEvent().
|
virtual |
Returns true if this event provides format mimeType; otherwise returns false.
Reimplemented from QMimeSource.
Definition at line 2723 of file qevent.cpp.
void QDropEvent::setDropAction | ( | Qt::DropAction | action | ) |
Sets the action to be performed on the data by the target.
Use this to override the proposed action with one of the possible actions.
If you set a drop action that is not one of the possible actions, the drag and drop operation will default to a copy operation.
Once you have supplied a replacement drop action, call accept() instead of acceptProposedAction().
Definition at line 2746 of file qevent.cpp.
Referenced by QGraphicsProxyWidget::dragMoveEvent(), QGraphicsView::dragMoveEvent(), QOleDropTarget::DragOver(), QOleDropTarget::Drop(), QGraphicsView::dropEvent(), QAbstractItemView::dropEvent(), handle_xdnd_position(), QX11Data::motifdndHandle(), and QOleDropTarget::sendDragEnterEvent().
QWidget * QDropEvent::source | ( | ) | const |
If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns 0.
The source of the operation is the first parameter to the QDrag object used instantiate the drag.
This is useful if your widget needs special behavior when dragging to itself.
Definition at line 2739 of file qevent.cpp.
Referenced by QAbstractItemView::dragEnterEvent(), QAbstractItemView::dragMoveEvent(), QLineEdit::dropEvent(), QListWidget::dropEvent(), QTableWidget::dropEvent(), QAbstractItemView::dropEvent(), QTreeWidget::dropEvent(), QAbstractItemViewPrivate::droppingOnItself(), QIconModeViewBase::filterDragMoveEvent(), QIconModeViewBase::filterDropEvent(), QGraphicsViewPrivate::populateSceneDragDropEvent(), and QTextControl::processEvent().
|
friend |
|
protected |
Definition at line 522 of file qevent.h.
Referenced by QDropEvent(), and setDropAction().
|
protected |
Definition at line 524 of file qevent.h.
Referenced by QDropEvent(), and setDropAction().
|
protected |
Definition at line 523 of file qevent.h.
Referenced by QDropEvent(), and setDropAction().
|
mutableprotected |
|
protected |
Definition at line 525 of file qevent.h.
Referenced by encodedData(), format(), and provides().
|
protected |
Definition at line 519 of file qevent.h.
Referenced by QApplication::notify().