QMouseEvent Class
QMouseEvent 클래스에는 마우스 이벤트를 설명하는 매개변수가 포함되어 있습니다. 더 보기...
Header: | #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 |
상세 설명
마우스 이벤트는 위젯 내에서 마우스 버튼을 누르거나 놓을 때, 또는 마우스 커서를 움직일 때 발생합니다.
마우스 이동 이벤트는 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 은 모든 키보드 수정자의 상태입니다.
Qt::MouseEventFlags QMouseEvent::flags() const
마우스 이벤트 플래그를 반환합니다.
마우스 이벤트 플래그는 마우스 이벤트에 대한 추가 정보를 제공합니다.
Qt::MouseEventFlag 및 QGraphicsSceneMouseEvent::flags()도 참조하세요 .
© 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.