Qt Quick 예제 - 마우스 영역
다음은 QML의 MouseArea 유형의 예입니다.
MouseArea 예제는 MouseArea 로 클릭 및 드래그에 응답하는 방법을 보여줍니다. 자세한 내용은 Qt Quick - 사용자 입력의 중요 개념을 참조하세요.
예제 실행하기
에서 예제를 실행하려면 Qt Creator에서 Welcome 모드를 열고 Examples 에서 예제를 선택합니다. 자세한 내용은 예제 빌드 및 실행하기를 참조하세요.
마우스 영역 동작
빨간색 사각형 안쪽을 클릭하면 Text 유형에 QML에서 사용할 수 있는 여러 속성이 나열됩니다. 마우스를 누르고 MouseArea 안에 있는 동안 빨간색 사각형의 불투명도는 감소합니다.
클릭이나 기타 개별 작업이 발생하면 MouseArea 에서 신호가 방출됩니다.
onPressAndHold: btn.text = qsTr('Press and hold') onClicked: (mouse) => { btn.text = qsTr('Clicked (wasHeld=') + mouse.wasHeld + ')' } onDoubleClicked: btn.text = qsTr('Double clicked')
MouseArea 를 사용하여 항목을 드래그할 수도 있습니다. 드래그 속성의 매개변수를 설정하면 사용자가 마우스 영역 경계 내에서 드래그하기 시작하면 대상 항목이 드래그됩니다.
drag.target: blueSquare drag.axis: Drag.XAndYAxis drag.minimumX: 0 drag.maximumX: box.width - parent.width drag.minimumY: 0 drag.maximumY: box.height - parent.width
© 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.