이 페이지에서

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

보호된 함수

QDropEvent(QDropEvent &&)
QDropEvent &operator=(QDropEvent &&)
QDropEvent &operator=(const QDropEvent &other)

자세한 설명

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

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

제안된 드롭 동작이 적합하지 않은 경우(예: 사용자 정의 위젯이 해당 동작을 지원하지 않는 경우), setDropAction() 함수를 호출하여 원하는 동작을 지정함으로써 possible drop actions 중 하나로 대체할 수 있습니다. possibleActions()가 반환하는 값들의 비트별 OR 조합에 포함되지 않은 값을 설정하면 기본 복사 동작이 사용됩니다. 대체 드롭 동작이 설정되면, 드롭 작업을 완료하기 위해 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 인코딩된 데이터로 저장됩니다.

드롭 시점의 마우스 버튼 및 키보드 수정키 상태는 buttons 및 modifiers 에 의해 지정됩니다.

[protected delete] QDropEvent::QDropEvent(QDropEvent &&)

QDropEvent 의 인스턴스를 move-construct로 생성합니다. 이 함수는 삭제되었습니다.

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 ’을 설정합니다. 이 기능을 사용하여 ‘ proposed action ’을 ‘ possible actions ’ 중 하나로 재정의할 수 있습니다.

허용된 작업이 아닌 드롭 작업을 설정하면, 드래그 앤 드롭 작업은 기본적으로 복사 작업으로 처리됩니다.

대체 드롭 동작을 지정한 후에는 acceptProposedAction() 대신 accept()을 호출하십시오.

dropAction()도 참조하십시오 .

QObject *QDropEvent::source() const

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

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

QDrag::QDrag()도 참조하십시오 .

[protected delete] QDropEvent &QDropEvent::operator=(QDropEvent &&)

other 를 이 QDropEvent 인스턴스에 할당합니다. 이 함수는 삭제됩니다.

[noexcept protected default] QDropEvent &QDropEvent::operator=(const QDropEvent &other)

other 를 이 QDropEvent 인스턴스에 복사-할당합니다.

© 2026 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.