QMouseEvent Class
QMouseEvent 클래스에는 마우스 이벤트를 설명하는 매개변수들이 포함되어 있습니다. 더 보기...
| 헤더: | #include <QMouseEvent> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
| 상속: | QSinglePointEvent |
- 상속된 멤버를 포함한 모든 멤버 목록
- 사용 중단된 멤버
- QMouseEvent는 이벤트 클래스의 일부입니다.
공개 함수
| QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()) | |
| QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()) | |
| Qt::MouseEventFlags | flags() const |
보호된 함수
| QMouseEvent(QMouseEvent &&) | |
| QMouseEvent & | operator=(QMouseEvent &&) |
| QMouseEvent & | operator=(const QMouseEvent &other) |
상세 설명
마우스 이벤트는 위젯 내에서 마우스 버튼이 눌리거나 놓일 때, 또는 마우스 커서가 이동할 때 발생합니다.
QWidget::setMouseTracking()를 통해 마우스 추적 기능이 활성화되지 않은 경우, 마우스 이동 이벤트는 마우스 버튼이 눌려진 상태에서만 발생합니다.
위젯 내부에서 마우스 버튼이 눌리면 Qt는 자동으로 마우스를 잡으며, 위젯은 마지막 마우스 버튼이 놓일 때까지 마우스 이벤트를 계속 수신합니다.
마우스 이벤트에는 수신자가 해당 이벤트를 원하는지 여부를 나타내는 특수한 수락 플래그가 포함되어 있습니다. 위젯에서 마우스 이벤트를 처리하지 않는 경우, ignore()를 호출해야 합니다. 마우스 이벤트는 accept()를 통해 위젯이 이벤트를 수락하거나 이벤트 필터가 이벤트를 처리할 때까지 상위 위젯 체인을 따라 전달됩니다.
참고: 마우스 이벤트가 Qt::WA_NoMousePropagation 가 설정된 widget 로 전파된경우 , 해당 마우스 이벤트는 더 이상 상위 위젯 체인으로 전파되지 않습니다.
키보드 수정 키의 상태는 QInputEvent 에서 상속받은 modifiers() 함수를 호출하여 확인할 수 있습니다.
position() 함수는 마우스 이벤트를 수신하는 위젯이나 항목을 기준으로 한 커서 위치를 반환합니다. 마우스 이벤트의 결과로 위젯을 이동시키는 경우, 흔들리는 움직임을 방지하려면 globalPosition()가 반환하는 전역 위치를 사용하십시오.
QWidget::setEnabled() 함수는 위젯에 대한 마우스 및 키보드 이벤트를 활성화하거나 비활성화하는 데 사용할 수 있습니다.
QWidget 이벤트 핸들러인 QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent() 및 QWidget::mouseMoveEvent()를 재구현하여 사용자 정의 위젯에서 마우스 이벤트를 수신할 수 있습니다.
QWidget::setMouseTracking(), QWidget::grabMouse() 및 QCursor::pos()도 참조하십시오 .
멤버 함수 문서
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice())
device 에서 발생한 마우스 이벤트 객체를 생성합니다.
type 매개변수는 QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick 또는 QEvent::MouseMove 중 하나여야 합니다.
localPos 는 수신 위젯 또는 항목에 대한 마우스 커서의 상대적 위치입니다. 화면 좌표계에서 커서의 위치는 ` globalPos`로 지정됩니다. 창 위치는 ` localPos`과 동일한 값으로 설정됩니다. 이벤트를 발생시킨 ` button `는 ` Qt::MouseButton ` 열거형의 값으로 제공됩니다. 이벤트 ` type `가 ` MouseMove`인 경우, 이 이벤트에 해당하는 버튼은 ` Qt::NoButton`입니다. ` buttons `는 이벤트 발생 시점의 모든 버튼 상태이며, ` modifiers `는 모든 키보드 수정키의 상태입니다.
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice())
마우스 이벤트 객체를 생성합니다.
type 매개변수는 QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick 또는 QEvent::MouseMove 중 하나여야 합니다.
localPos, scenePos 및 globalPos 는 각각 수신 위젯이나 항목, 창, 화면 또는 바탕화면을 기준으로 한 마우스 커서의 위치를 지정합니다.
이벤트를 유발한 button 는 Qt::MouseButton 열거형의 값으로 제공됩니다. 이벤트 type 가 MouseMove 인 경우, 이 이벤트에 해당하는 버튼은 Qt::NoButton 입니다. buttons 는 이벤트 발생 시점의 모든 버튼 상태이며, modifiers 는 모든 키보드 수정키의 상태입니다.
[protected delete] QMouseEvent::QMouseEvent(QMouseEvent &&)
QMouseEvent 의 인스턴스를 move-construct로 생성합니다. 이 함수는 삭제되었습니다.
Qt::MouseEventFlags QMouseEvent::flags() const
마우스 이벤트 플래그를 반환합니다.
마우스 이벤트 플래그는 마우스 이벤트에 대한 추가 정보를 제공합니다.
Qt::MouseEventFlag 및 QGraphicsSceneMouseEvent::flags()도 참조하십시오 .
[protected delete] QMouseEvent &QMouseEvent::operator=(QMouseEvent &&)
other 를 이 QMouseEvent 인스턴스에 할당합니다. 이 함수는 삭제됩니다.
[noexcept protected default] QMouseEvent &QMouseEvent::operator=(const QMouseEvent &other)
other 를 이 QMouseEvent 인스턴스에 복사-할당합니다.
© 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.