Struct qt_gui::QDropEvent

source ·
#[repr(C)]
pub struct QDropEvent { /* private fields */ }
Expand description

The QDropEvent class provides an event which is sent when a drag and drop action is completed.

C++ class: QDropEvent.

C++ documentation:

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.

Implementations§

source§

impl QDropEvent

source

pub unsafe fn accept_proposed_action(&self)

Sets the drop action to be the proposed action.

Calls C++ function: void QDropEvent::acceptProposedAction().

C++ documentation:

Sets the drop action to be the proposed action.

See also setDropAction(), proposedAction(), and accept().

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QDropEvent>> ) -> Ref<QDropEvent>

The QDropEvent class provides an event which is sent when a drag and drop action is completed.

Calls C++ function: QDropEvent& QDropEvent::operator=(const QDropEvent& other).

C++ documentation:

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.

source

pub unsafe fn drop_action(&self) -> DropAction

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.

Calls C++ function: Qt::DropAction QDropEvent::dropAction() const.

C++ documentation:

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.

See also setDropAction().

source

pub unsafe fn keyboard_modifiers(&self) -> QFlags<KeyboardModifier>

Returns the modifier keys that are pressed.

Calls C++ function: QFlags<Qt::KeyboardModifier> QDropEvent::keyboardModifiers() const.

C++ documentation:

Returns the modifier keys that are pressed.

source

pub unsafe fn mime_data(&self) -> QPtr<QMimeData>

Returns the data that was dropped on the widget and its associated MIME type information.

Calls C++ function: const QMimeData* QDropEvent::mimeData() const.

C++ documentation:

Returns the data that was dropped on the widget and its associated MIME type information.

source

pub unsafe fn mouse_buttons(&self) -> QFlags<MouseButton>

Returns the mouse buttons that are pressed..

Calls C++ function: QFlags<Qt::MouseButton> QDropEvent::mouseButtons() const.

C++ documentation:

Returns the mouse buttons that are pressed..

source

pub unsafe fn new_6a( pos: impl CastInto<Ref<QPointF>>, actions: QFlags<DropAction>, data: impl CastInto<Ptr<QMimeData>>, buttons: QFlags<MouseButton>, modifiers: QFlags<KeyboardModifier>, type_: Type ) -> CppBox<QDropEvent>

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.

Calls C++ function: [constructor] void QDropEvent::QDropEvent(const QPointF& pos, QFlags<Qt::DropAction> actions, const QMimeData* data, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers, QEvent::Type type = …).

C++ documentation:

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.

source

pub unsafe fn new_5a( pos: impl CastInto<Ref<QPointF>>, actions: QFlags<DropAction>, data: impl CastInto<Ptr<QMimeData>>, buttons: QFlags<MouseButton>, modifiers: QFlags<KeyboardModifier> ) -> CppBox<QDropEvent>

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.

Calls C++ function: [constructor] void QDropEvent::QDropEvent(const QPointF& pos, QFlags<Qt::DropAction> actions, const QMimeData* data, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers).

C++ documentation:

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.

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QDropEvent>> ) -> CppBox<QDropEvent>

The QDropEvent class provides an event which is sent when a drag and drop action is completed.

Calls C++ function: [constructor] void QDropEvent::QDropEvent(const QDropEvent& other).

C++ documentation:

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.

source

pub unsafe fn pos(&self) -> CppBox<QPoint>

Returns the position where the drop was made.

Calls C++ function: QPoint QDropEvent::pos() const.

C++ documentation:

Returns the position where the drop was made.

source

pub unsafe fn pos_f(&self) -> Ref<QPointF>

Returns the position where the drop was made.

Calls C++ function: const QPointF& QDropEvent::posF() const.

C++ documentation:

Returns the position where the drop was made.

source

pub unsafe fn possible_actions(&self) -> QFlags<DropAction>

Returns an OR-combination of possible drop actions.

Calls C++ function: QFlags<Qt::DropAction> QDropEvent::possibleActions() const.

C++ documentation:

Returns an OR-combination of possible drop actions.

See also dropAction().

source

pub unsafe fn proposed_action(&self) -> DropAction

Returns the proposed drop action.

Calls C++ function: Qt::DropAction QDropEvent::proposedAction() const.

C++ documentation:

Returns the proposed drop action.

See also dropAction().

source

pub unsafe fn set_drop_action(&self, action: DropAction)

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.

Calls C++ function: void QDropEvent::setDropAction(Qt::DropAction action).

C++ documentation:

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().

See also dropAction().

source

pub unsafe fn source(&self) -> QPtr<QObject>

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.

Calls C++ function: QObject* QDropEvent::source() const.

C++ documentation:

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.

See also QDrag::QDrag().

Methods from Deref<Target = QEvent>§

source

pub unsafe fn accept(&self)

Sets the accept flag of the event object, the equivalent of calling setAccepted(true).

Calls C++ function: void QEvent::accept().

C++ documentation:

Sets the accept flag of the event object, the equivalent of calling setAccepted(true).

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget.

See also ignore().

source

pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QEvent>>) -> Ref<QEvent>

Calls C++ function: QEvent& QEvent::operator=(const QEvent& other).

source

pub unsafe fn ignore(&self)

Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).

Calls C++ function: void QEvent::ignore().

C++ documentation:

Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).

Clearing the accept parameter indicates that the event receiver does not want the event. Unwanted events might be propagated to the parent widget.

See also accept().

source

pub unsafe fn is_accepted(&self) -> bool

the accept flag of the event object

Calls C++ function: bool QEvent::isAccepted() const.

C++ documentation:

the accept flag of the event object

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.

For convenience, the accept flag can also be set with accept(), and cleared with ignore().

Access functions:

bool isAccepted() const
void setAccepted(bool accepted)
source

pub unsafe fn set_accepted(&self, accepted: bool)

the accept flag of the event object

Calls C++ function: void QEvent::setAccepted(bool accepted).

C++ documentation:

the accept flag of the event object

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.

For convenience, the accept flag can also be set with accept(), and cleared with ignore().

Access functions:

bool isAccepted() const
void setAccepted(bool accepted)
source

pub unsafe fn spontaneous(&self) -> bool

Returns true if the event originated outside the application (a system event); otherwise returns false.

Calls C++ function: bool QEvent::spontaneous() const.

C++ documentation:

Returns true if the event originated outside the application (a system event); otherwise returns false.

The return value of this function is not defined for paint events.

source

pub unsafe fn type_(&self) -> Type

Returns the event type.

Calls C++ function: QEvent::Type QEvent::type() const.

C++ documentation:

Returns the event type.

Trait Implementations§

source§

impl CppDeletable for QDropEvent

source§

unsafe fn delete(&self)

Calls C++ function: virtual [destructor] void QDropEvent::~QDropEvent().

source§

impl Deref for QDropEvent

source§

fn deref(&self) -> &QEvent

Calls C++ function: QEvent* static_cast<QEvent*>(QDropEvent* ptr).

§

type Target = QEvent

The resulting type after dereferencing.
source§

impl DynamicCast<QDragEnterEvent> for QDropEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QDropEvent>) -> Ptr<QDragEnterEvent>

Calls C++ function: QDragEnterEvent* dynamic_cast<QDragEnterEvent*>(QDropEvent* ptr).

source§

impl DynamicCast<QDragMoveEvent> for QDropEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QDropEvent>) -> Ptr<QDragMoveEvent>

Calls C++ function: QDragMoveEvent* dynamic_cast<QDragMoveEvent*>(QDropEvent* ptr).

source§

impl DynamicCast<QDropEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QDropEvent>

Calls C++ function: QDropEvent* dynamic_cast<QDropEvent*>(QEvent* ptr).

source§

impl StaticDowncast<QDragEnterEvent> for QDropEvent

source§

unsafe fn static_downcast(ptr: Ptr<QDropEvent>) -> Ptr<QDragEnterEvent>

Calls C++ function: QDragEnterEvent* static_cast<QDragEnterEvent*>(QDropEvent* ptr).

source§

impl StaticDowncast<QDragMoveEvent> for QDropEvent

source§

unsafe fn static_downcast(ptr: Ptr<QDropEvent>) -> Ptr<QDragMoveEvent>

Calls C++ function: QDragMoveEvent* static_cast<QDragMoveEvent*>(QDropEvent* ptr).

source§

impl StaticDowncast<QDropEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QDropEvent>

Calls C++ function: QDropEvent* static_cast<QDropEvent*>(QEvent* ptr).

source§

impl StaticUpcast<QDropEvent> for QDragEnterEvent

source§

unsafe fn static_upcast(ptr: Ptr<QDragEnterEvent>) -> Ptr<QDropEvent>

Calls C++ function: QDropEvent* static_cast<QDropEvent*>(QDragEnterEvent* ptr).

source§

impl StaticUpcast<QDropEvent> for QDragMoveEvent

source§

unsafe fn static_upcast(ptr: Ptr<QDragMoveEvent>) -> Ptr<QDropEvent>

Calls C++ function: QDropEvent* static_cast<QDropEvent*>(QDragMoveEvent* ptr).

source§

impl StaticUpcast<QEvent> for QDropEvent

source§

unsafe fn static_upcast(ptr: Ptr<QDropEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QDropEvent* ptr).

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.