이 페이지에서

KeyEvent QML Type (Uncreatable)

주요 이벤트에 대한 정보를 제공합니다. 더 보기...

Import Statement: import QtQuick

참고: 이 타입은 생성할 수 없습니다. QML에서 인스턴스화할 수 없습니다.

속성

방법

  • bool matches(StandardKey matchKey)

자세한 설명

예를 들어, 다음 코드는 Enter 키를 누를 때 Item의 state 속성을 변경합니다:

Item {
    focus: true
    Keys.onPressed: (event)=> { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
}

속성 설명

accepted : bool

accepted 를 true로 설정하면 키 이벤트가 해당 항목의 상위 항목으로 전파되는 것을 방지합니다.

일반적으로, 항목이 키 이벤트에 반응하는 경우, 상위 항목들이 동일한 이벤트에 반응하지 않도록 해당 이벤트를 수락해야 합니다.

count : int [read-only]

이 속성은 해당 이벤트에 관련된 키의 개수를 저장합니다. ` KeyEvent::text `가 비어 있지 않은 경우, 이 값은 단순히 해당 문자열의 길이입니다.

isAutoRepeat : bool [read-only]

이 속성은 해당 이벤트가 자동 반복 키에서 발생한 것인지 여부와 관계없이 적용됩니다.

key : int [read-only]

이 속성은 눌리거나 놓인 키의 코드를 저장합니다.

키보드 코드 목록은 Qt.Key 을 참조하십시오. 이 코드들은 기본이 되는 윈도우 시스템과 무관합니다. 이 함수는 대문자와 소문자를 구분하지 않으므로, 이를 구분하려면 text 속성을 사용하십시오.

값이 0이거나 Qt.Key_Unknown 인 경우, 해당 이벤트는 알려진 키의 결과가 아닙니다. 예를 들어, 컴포즈 시퀀스, 키보드 매크로 또는 키 이벤트 압축의 결과일 수 있습니다.

modifiers : int [read-only]

이 속성은 이벤트가 발생하기 직전에 존재했던 키보드 수정자 플래그를 포함합니다.

이 속성은 숫자 값들의 비트 단위 조합을 포함합니다( Qt::KeyboardModifier 에서와 동일함):

상수설명
Qt.NoModifier모디파이어 키가 눌려 있지 않습니다.
Qt.ShiftModifier키보드의 Shift 키가 눌려 있습니다.
Qt.ControlModifier키보드의 Ctrl 키가 눌려 있습니다.
Qt.AltModifier키보드의 Alt 키가 눌립니다.
Qt.MetaModifier키보드의 Meta 키가 눌렸습니다.
Qt.KeypadModifier키패드 버튼이 눌렸습니다.
Qt.GroupSwitchModifierX11 전용입니다. 키보드의 Mode_switch 키가 눌렸습니다.

예를 들어, Shift 키 + Enter 키 조합에 반응하려면:

Item {
    focus: true
    Keys.onPressed: (event)=> {
        if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
            doSomething();
    }
}

nativeScanCode : quint32 [read-only]

이 속성에는 눌린 키의 네이티브 스캔 코드가 포함됩니다. 이 값은 QKeyEvent 에서 변경 없이 그대로 전달됩니다.

QKeyEvent::nativeScanCode()도 참조하십시오 .

text : string [read-only]

이 속성은 키가 생성한 유니코드 텍스트를 저장합니다. Shift, Control, Alt, Meta와 같은 수정 키가 눌리거나 놓이는 경우, 반환되는 텍스트는 빈 문자열일 수 있습니다. 이러한 경우 key 에는 유효한 값이 포함됩니다.

메서드 문서

bool matches(StandardKey matchKey)

키 이벤트가 지정된 표준 matchKey 과 일치하면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다.

Item {
    focus: true
    Keys.onPressed: (event)=> {
        if (event.matches(StandardKey.Undo))
            myModel.undo();
        else if (event.matches(StandardKey.Redo))
            myModel.redo();
    }
}

QKeySequence::StandardKey도 참조하십시오 .

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