#include <qevent.h>
Inheritance diagram for QDropEvent:


When a widget {QWidget::setAcceptDrops()}{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 {possibleActions()}{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.
Definition at line 434 of file qevent.h.
Public Member Functions | |
| QDropEvent (const QPoint &pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type=Drop) | |
| ~QDropEvent () | |
| const QPoint & | pos () const |
| Qt::MouseButtons | mouseButtons () const |
| Qt::KeyboardModifiers | keyboardModifiers () const |
| Qt::DropActions | possibleActions () const |
| Qt::DropAction | proposedAction () const |
| void | acceptProposedAction () |
| Qt::DropAction | dropAction () const |
| void | setDropAction (Qt::DropAction action) |
| QWidget * | source () const |
| const QMimeData * | mimeData () const |
| const char * | format (int n=0) const |
| QByteArray | encodedData (const char *) const |
| bool | provides (const char *) const |
Protected Attributes | |
| QPoint | p |
| Qt::MouseButtons | mouseState |
| Qt::KeyboardModifiers | modState |
| Qt::DropActions | act |
| Qt::DropAction | drop_action |
| Qt::DropAction | default_action |
| const QMimeData * | mdata |
| QList< QByteArray > | fmts |
Friends | |
| class | QApplication |
| 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 2148 of file qevent.cpp.
References act, default_action, QDragManager::defaultAction(), QEvent::ignore(), and QDragManager::self().
02150 : QEvent(type), p(pos), mouseState(buttons), 02151 modState(modifiers), act(actions), 02152 drop_action(Qt::CopyAction), 02153 mdata(data) 02154 { 02155 default_action = QDragManager::self()->defaultAction(act, modifiers); 02156 ignore(); 02157 }
Here is the call graph for this function:

| QDropEvent::~QDropEvent | ( | ) |
| const QPoint & QDropEvent::pos | ( | ) | const [inline] |
Returns the position where the drop was made.
Definition at line 444 of file qevent.h.
References p.
Referenced by Q3ListView::contentsDragEnterEvent(), Q3Table::contentsDragEnterEvent(), Q3IconView::contentsDragEnterEvent(), Q3Table::contentsDragMoveEvent(), Q3ListView::contentsDragMoveEvent(), Q3IconView::contentsDragMoveEvent(), Q3IconView::contentsDropEvent(), Q3ListView::contentsDropEvent(), qdesigner_internal::QrcView::dragMoveEvent(), QListView::dragMoveEvent(), QColorWell::dragMoveEvent(), QLineEdit::dragMoveEvent(), QColorWell::dropEvent(), qdesigner_internal::QrcView::dropEvent(), QLineEdit::dropEvent(), QAbstractItemViewPrivate::dropOn(), QDesignerTabWidget::eventFilter(), QApplication::notify(), QGraphicsViewPrivate::populateSceneDragDropEvent(), QTextControl::processEvent(), Q3ScrollView::viewportDragEnterEvent(), QFileListBox::viewportDragMoveEvent(), Q3FileDialogQFileListView::viewportDragMoveEvent(), Q3ScrollView::viewportDragMoveEvent(), and Q3ScrollView::viewportDropEvent().
00444 { return p; }
| Qt::MouseButtons QDropEvent::mouseButtons | ( | ) | const [inline] |
Returns the mouse buttons that are pressed..
Definition at line 445 of file qevent.h.
Referenced by QApplication::notify(), and QGraphicsViewPrivate::populateSceneDragDropEvent().
00445 { return mouseState; }
| Qt::KeyboardModifiers QDropEvent::keyboardModifiers | ( | ) | const [inline] |
Returns the modifier keys that are pressed.
Definition at line 446 of file qevent.h.
Referenced by QApplication::notify(), and QGraphicsViewPrivate::populateSceneDragDropEvent().
00446 { return modState; }
| Qt::DropActions QDropEvent::possibleActions | ( | ) | const [inline] |
Returns an OR-combination of possible drop actions.
Definition at line 448 of file qevent.h.
Referenced by QApplication::notify(), and QGraphicsViewPrivate::populateSceneDragDropEvent().
00448 { return act; }
| Qt::DropAction QDropEvent::proposedAction | ( | ) | const [inline] |
Returns the proposed drop action.
Definition at line 449 of file qevent.h.
Referenced by qdesigner_internal::QrcView::acceptDrop(), QAbstractItemViewPrivate::canDecode(), QAbstractItemViewPrivate::dropOn(), QGraphicsViewPrivate::populateSceneDragDropEvent(), and QTextControl::processEvent().
00449 { return default_action; }
| void QDropEvent::acceptProposedAction | ( | ) | [inline] |
Sets the drop action to be the proposed action.
Definition at line 450 of file qevent.h.
References QEvent::accept().
Referenced by qdesigner_internal::QrcView::acceptDrop(), QLineEdit::dragMoveEvent(), QLineEdit::dropEvent(), QDesignerTabWidget::eventFilter(), and QTextControl::processEvent().
00450 { drop_action = default_action; accept(); }
Here is the call graph for this function:

| Qt::DropAction QDropEvent::dropAction | ( | ) | const [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 452 of file qevent.h.
Referenced by QLineEdit::dropEvent(), handle_xdnd_position(), QX11Data::motifdndHandle(), QGraphicsViewPrivate::populateSceneDragDropEvent(), and QX11Data::xdndHandleDrop().
00452 { return drop_action; }
| void QDropEvent::setDropAction | ( | Qt::DropAction | action | ) |
Sets the action to be performed on the data by the target. Use this to override the {proposedAction()}{proposed action} with one of the {possibleActions()}{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 2240 of file qevent.cpp.
References act, Qt::CopyAction, drop_action, and Qt::IgnoreAction.
Referenced by handle_xdnd_position(), and QX11Data::motifdndHandle().
02241 { 02242 if (!(action & act) && action != Qt::IgnoreAction) 02243 action = Qt::CopyAction; 02244 drop_action = action; 02245 }
| 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 2233 of file qevent.cpp.
References QDragManager::self(), and QDragManager::source().
Referenced by Q3Table::contentsDragEnterEvent(), Q3Table::contentsDragMoveEvent(), Q3IconView::contentsDragMoveEvent(), Q3IconView::contentsDropEvent(), QListView::dragMoveEvent(), QLineEdit::dropEvent(), QGraphicsViewPrivate::populateSceneDragDropEvent(), QTextControl::processEvent(), QFileListBox::viewportDragMoveEvent(), and Q3FileDialogQFileListView::viewportDragMoveEvent().
02234 { 02235 QDragManager *manager = QDragManager::self(); 02236 return manager ? manager->source() : 0; 02237 }
Here is the call graph for this function:

| const QMimeData * QDropEvent::mimeData | ( | ) | const [inline] |
Returns the data that was dropped on the widget and its associated MIME type information.
Definition at line 456 of file qevent.h.
Referenced by qdesigner_internal::QrcView::acceptDrop(), QAbstractItemViewPrivate::canDecode(), QColorWell::dragEnterEvent(), ColorButton::dragEnterEvent(), QColorShowLabel::dragEnterEvent(), ColorButton::dragMoveEvent(), QColorWell::dragMoveEvent(), QLineEdit::dragMoveEvent(), ColorButton::dropEvent(), QColorWell::dropEvent(), qdesigner_internal::QrcView::dropEvent(), QLineEdit::dropEvent(), QColorShowLabel::dropEvent(), QDesignerTabWidget::eventFilter(), QApplication::notify(), QGraphicsViewPrivate::populateSceneDragDropEvent(), and QTextControl::processEvent().
00456 { return mdata; }
| const char * QDropEvent::format | ( | int | n = 0 |
) | const [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 2197 of file qevent.cpp.
References QList< T >::append(), QList< T >::at(), QByteArray::constData(), fmts, QMimeData::formats(), i, QList< T >::isEmpty(), mdata, and QList< T >::size().
02198 { 02199 if (fmts.isEmpty()) { 02200 QStringList formats = mdata->formats(); 02201 for (int i = 0; i < formats.size(); ++i) 02202 fmts.append(formats.at(i).toLatin1()); 02203 } 02204 if (n < 0 || n >= fmts.size()) 02205 return 0; 02206 return fmts.at(n).constData(); 02207 }
Here is the call graph for this function:

| QByteArray QDropEvent::encodedData | ( | const char * | format | ) | const [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 2179 of file qevent.cpp.
References QMimeData::data(), and mdata.
02180 { 02181 return mdata->data(QLatin1String(format)); 02182 }
Here is the call graph for this function:

| bool QDropEvent::provides | ( | const char * | mimeType | ) | const [virtual] |
Returns true if this event provides format mimeType; otherwise returns false.
Reimplemented from QMimeSource.
Definition at line 2217 of file qevent.cpp.
References QStringList::contains(), QMimeData::formats(), and mdata.
02218 { 02219 return mdata->formats().contains(QLatin1String(mimeType)); 02220 }
Here is the call graph for this function:

friend class QApplication [friend] |
QPoint QDropEvent::p [protected] |
Qt::MouseButtons QDropEvent::mouseState [protected] |
Qt::KeyboardModifiers QDropEvent::modState [protected] |
Qt::DropActions QDropEvent::act [protected] |
Qt::DropAction QDropEvent::drop_action [protected] |
Qt::DropAction QDropEvent::default_action [protected] |
const QMimeData* QDropEvent::mdata [protected] |
QList<QByteArray> QDropEvent::fmts [mutable, protected] |
1.5.1