QDropEvent Class

QDropEvent 클래스는 끌어서 놓기 동작이 완료될 때 전송되는 이벤트를 제공합니다. 더 보기...

헤더: #include <QDropEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
상속합니다: QEvent
상속 대상:

QDragMoveEvent

공용 함수

QDropEvent(const QPointF &pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QEvent::Type type = Drop)
void acceptProposedAction()
(since 6.0) Qt::MouseButtons buttons() const
Qt::DropAction dropAction() const
const QMimeData *mimeData() const
(since 6.0) Qt::KeyboardModifiers modifiers() const
(since 6.0) QPointF position() const
Qt::DropActions possibleActions() const
Qt::DropAction proposedAction() const
void setDropAction(Qt::DropAction action)
QObject *source() const

상세 설명

위젯이 accepts drop events, 가장 최근에 전송된 QDragEnterEvent 또는 QDragMoveEvent 을 수락한 경우 이 이벤트를 수신합니다.

드롭 이벤트에는 위젯이 수락하거나 무시할 수 있도록 proposedAction()에서 사용할 수 있는 제안된 액션이 포함되어 있습니다. 위젯에서 작업을 처리할 수 있는 경우 acceptProposedAction() 함수를 호출해야 합니다. 제안된 동작은 Qt::DropAction 값의 조합일 수 있으므로 이러한 값 중 하나를 기본 동작으로 선택하거나 사용자에게 선호하는 동작을 선택하도록 요청하는 것이 유용할 수 있습니다.

사용자 정의 위젯이 해당 동작을 지원하지 않아 제안된 드롭 동작이 적합하지 않은 경우 원하는 동작으로 setDropAction()을 호출하여 possible drop actions 중 하나로 대체할 수 있습니다. possibleActions ()에서 반환된 값의 비트 또는 조합에 없는 값을 설정하면 기본 복사 동작이 사용됩니다. 대체 삭제 작업이 설정되면 acceptProposedAction() 대신 accept()를 호출하여 삭제 작업을 완료합니다.

mimeData() 함수는 위젯에 드롭된 데이터를 QMimeData 객체로 제공합니다. 여기에는 데이터 자체 외에도 데이터의 MIME 유형에 대한 정보가 포함됩니다.

QMimeData, QDrag, 드래그 앤 드롭도참조하세요 .

멤버 함수 문서

QDropEvent::QDropEvent(const QPointF &pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QEvent::Type type = Drop)

대상 위젯의 좌표계에서 pos 으로 지정된 지점에 놓는 것에 해당하는 특정 type 의 드롭 이벤트를 생성합니다.

actions 은 어떤 유형의 드래그 앤 드롭 작업을 수행할 수 있는지를 나타내며, 드래그 데이터는 data 에 MIME 인코딩된 데이터로 저장됩니다.

드래그 당시 마우스 버튼과 키보드 수정자의 상태는 buttonsmodifiers 에 의해 지정됩니다.

void QDropEvent::acceptProposedAction()

드롭 동작을 제안된 동작으로 설정합니다.

setDropAction(), proposedAction() 및 accept()도 참조하세요 .

[since 6.0] Qt::MouseButtons QDropEvent::buttons() const

눌렀던 마우스 버튼을 반환합니다.

이 기능은 Qt 6.0에 도입되었습니다.

Qt::DropAction QDropEvent::dropAction() const

대상에 의해 데이터에 수행될 작업을 반환합니다. 명시적으로 드롭 작업을 선택하기 위해 setDropAction()을 호출한 경우 proposedAction()에 제공된 작업과 다를 수 있습니다.

setDropAction()도 참조하세요 .

const QMimeData *QDropEvent::mimeData() const

위젯에 드롭된 데이터와 관련 MIME 유형 정보를 반환합니다.

[since 6.0] Qt::KeyboardModifiers QDropEvent::modifiers() const

누른 수정자 키를 반환합니다.

이 함수는 Qt 6.0에 도입되었습니다.

[since 6.0] QPointF QDropEvent::position() const

드롭이 이루어진 위치를 반환합니다.

이 함수는 Qt 6.0에 도입되었습니다.

Qt::DropActions QDropEvent::possibleActions() const

가능한 드롭 동작의 OR 조합을 반환합니다.

dropAction()도 참조하세요 .

Qt::DropAction QDropEvent::proposedAction() const

제안된 드롭 액션을 반환합니다.

dropAction()도 참조하세요 .

void QDropEvent::setDropAction(Qt::DropAction action)

대상에 의해 데이터에 대해 수행될 action 을 설정합니다. 이를 사용하여 possible actions 중 하나로 proposed action 을 재정의할 수 있습니다.

가능한 동작 중 하나가 아닌 끌어서 놓기 동작을 설정하면 끌어서 놓기 작업은 기본적으로 복사 작업으로 설정됩니다.

대체 끌어서 놓기 동작을 지정한 후에는 acceptProposedAction() 대신 accept()를 호출합니다.

dropAction()도 참조하세요 .

QObject *QDropEvent::source() const

드래그 작업의 소스가 이 애플리케이션의 위젯인 경우 이 함수는 해당 소스를 반환하고, 그렇지 않으면 nullptr 을 반환합니다. 작업의 소스는 드래그 인스턴스화에 사용된 QDrag 객체의 첫 번째 매개변수입니다.

이 함수는 위젯을 드래그할 때 특별한 동작이 필요한 경우에 유용합니다.

QDrag::QDrag()도 참조하세요 .

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.