📄 qevent.cpp
字号:
\sa x() pos()*//*! \fn int QTabletEvent::z() const Returns the z position of the device. Typically this is represented by a wheel on a 4D Mouse. If the device does not support a Z-axis, this value is always zero. This is <em>not</em> the same as pressure. \sa pressure()*//*! \fn const QPoint &QTabletEvent::globalPos() const Returns the global position of the device \e{at the time of the event}. This is important on asynchronous windows systems like X11; whenever you move your widgets around in response to mouse events, globalPos() can differ significantly from the current position QCursor::pos(). \sa globalX() globalY() hiResGlobalPos()*//*! \fn int QTabletEvent::globalX() const Returns the global x position of the mouse pointer at the time of the event. \sa globalY() globalPos() hiResGlobalX()*//*! \fn int QTabletEvent::globalY() const Returns the global y position of the tablet device at the time of the event. \sa globalX() globalPos() hiResGlobalY()*//*! \fn qint64 QTabletEvent::uniqueId() const Returns a unique ID for the current device, making it possible to differentiate between multiple devices being used at the same time on the tablet. Values for the same device may vary from OS to OS. It is possible to generate a unique ID for any Wacom device.*//*! \fn const QPointF &QTabletEvent::hiResGlobalPos() const The high precision coordinates delivered from the tablet expressed. Sub pixeling information is in the fractional part of the QPointF. \sa globalPos() hiResGlobalX() hiResGlobalY()*//*! \fn qreal &QTabletEvent::hiResGlobalX() const The high precision x position of the tablet device.*//*! \fn qreal &QTabletEvent::hiResGlobalY() const The high precision y position of the tablet device.*/#ifndef QT_NO_DRAGANDDROP/*! Creates a QDragMoveEvent of the required \a type indicating that the mouse is at position \a pos given within a widget. The mouse and keyboard states are specified by \a buttons and \a modifiers, and the \a actions describe the types of drag and drop operation that are possible. The drag data is passed as MIME-encoded information in \a data. \warning Do not attempt to create a QDragMoveEvent yourself. These objects rely on Qt's internal state.*/QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type) : QDropEvent(pos, actions, data, buttons, modifiers, type) , rect(pos, QSize(1, 1)){}/*! Destroys the event.*/QDragMoveEvent::~QDragMoveEvent(){}/*! \fn void QDragMoveEvent::accept(bool y) Calls setAccepted(\a y) instead.*//*! \fn void QDragMoveEvent::accept(const QRect &rectangle) The same as accept(), but also notifies that future moves will also be acceptable if they remain within the \a rectangle given on the widget. This can improve performance, but may also be ignored by the underlying system. If the rectangle is empty, drag move events will be sent continuously. This is useful if the source is scrolling in a timer event.*//*! \fn void QDragMoveEvent::accept() \overload Calls QDropEvent::accept().*//*! \fn void QDragMoveEvent::ignore() \overload Calls QDropEvent::ignore().*//*! \fn void QDragMoveEvent::ignore(const QRect &rectangle) The opposite of the accept(const QRect&) function. Moves within the \a rectangle are not acceptable, and will be ignored.*//*! \fn QRect QDragMoveEvent::answerRect() const Returns the rectangle in the widget where the drop will occur if accepted. You can use this information to restrict drops to certain places on the widget.*//*! \class QDropEvent \ingroup events \ingroup draganddrop \brief The QDropEvent class provides an event which is sent when a drag and drop action is completed. When a widget \l{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 \l 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 required drop action is different to the proposed action, you can call setDropAction() 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. \sa QMimeData, QDrag, {Drag and Drop}*//*! \fn const QMimeData *QDropEvent::mimeData() const Returns the data that was dropped on the widget and its associated MIME type information.*//*! Constructs a drop event of a certain \a type corresponding to a drop at the point specified by \a pos in the destination widget's coordinate system. The \a actions indicate which types of drag and drop operation can be performed, and the drag data is stored as MIME-encoded data in \a data. The states of the mouse buttons and keyboard modifiers at the time of the drop are specified by \a buttons and \a modifiers.*/ // ### pos is in which coordinate system?QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type) : QEvent(type), p(pos), mouseState(buttons), modState(modifiers), act(actions), drop_action(Qt::CopyAction), mdata(data){ default_action = QDragManager::self()->defaultAction(act, modifiers); ignore();}/*! \internal */QDropEvent::~QDropEvent(){}/*! \compat Returns a byte array containing the drag's data, in \a 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 \a format. The resulting data will have a size of 0 if the format was not available. \sa format() QByteArray::size()*/QByteArray QDropEvent::encodedData(const char *format) const{ return mdata->data(QLatin1String(format));}/*! \compat Returns a string describing one of the available data types for this drag. Common examples are "text/plain" and "image/gif". If \a 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(). \sa data() provides()*/const char* QDropEvent::format(int n) const{ if (fmts.isEmpty()) { QStringList formats = mdata->formats(); for (int i = 0; i < formats.size(); ++i) fmts.append(formats.at(i).toLatin1()); } if (n < 0 || n >= fmts.size()) return 0; return fmts.at(n).constData();}/*! \compat Returns true if this event provides format \a mimeType; otherwise returns false. \sa data()*/bool QDropEvent::provides(const char *mimeType) const{ return mdata->formats().contains(QLatin1String(mimeType));}/*! 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. \sa QDrag::QDrag()*/QWidget* QDropEvent::source() const{ QDragManager *manager = QDragManager::self(); return manager ? manager->source() : 0;}void QDropEvent::setDropAction(Qt::DropAction action){ if (!(action & act) && action != Qt::IgnoreAction) action = Qt::CopyAction; drop_action = action;}/*! \fn const QPoint& QDropEvent::pos() const Returns the position where the drop was made.*//*! \fn Qt::MouseButtons QDropEvent::mouseButtons() const Returns the mouse buttons that are pressed..*//*! \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const Returns the modifier keys that are pressed.*//*! \fn void QDropEvent::accept() \internal*//*! \fn void QDropEvent::accept(bool accept) Call setAccepted(\a accept) instead.*//*! \fn void QDropEvent::acceptAction(bool accept = true) Call this to indicate that the action described by action() is accepted (i.e. if \a accept is true, which is the default), not merely the default copy action. If you call acceptAction(true), there is no need to also call accept(true).*//*! \enum QDropEvent::Action \compat When a drag and drop action is completed, the target is expected to perform an action on the data provided by the source. This will be one of the following: \value Copy The default action. The source simply uses the data provided in the operation. \value Link The source should somehow create a link to the location specified by the data. \value Move The source should somehow move the object from the location specified by the data to a new location. \value Private The target has special knowledge of the MIME type, which the source should respond to in a similar way to a Copy. \value UserAction The source and target can co-operate using special actions. This feature is not currently supported. The Link and Move actions only makes sense if the data is a reference, for example, text/uri-list file lists (see QUriDrag).*//*! \fn void QDropEvent::setDropAction(Qt::DropAction action) Sets the \a action to be performed on the data by the target. Use this to override the \l{proposedAction()}{proposed action} with one of the \l{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. \sa dropAction()*//*! \fn Qt::DropAction QDropEvent::dropAction() const Returns the action that the target is expected to perform on the data. If your application understands the action and can process the supplied data, call acceptAction(); if your application can process the supplied data but can only perform the Copy action, call accept(). \sa setDropAction()*//*! \fn Qt::DropActions QDropEvent::possibleActions() const Returns an OR-combination of possible drop actions. \sa dropAction()*//*! \fn Qt::DropAction QDropEvent::proposedAction() const Returns the proposed drop action. \sa dropAction()*//*! \fn void QDropEvent::acceptProposedAction() Sets the drop action to be the proposed action. \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}*/#ifdef QT3_SUPPORT/*! Use dropAction() instead. The table below shows the correspondance between the return type of action() and the return type of dropAction(). \table \header \i Old enum value \i New enum value \row \i QDropEvent::Copy \i Qt::CopyAction \row \i QDropEvent::Move \i Qt::MoveAction \row \i QDropEvent::Link \i Qt::LinkAction \row \i other \i Qt::CopyAction \endtable*/QT3_SUPPORT QDropEvent::Action QDropEvent::action() const{ switch(drop_action) { case Qt::CopyAction: return Copy; case Qt::MoveAction: return Move; case Qt::LinkAction: return Li
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -