이 페이지에서

Qt Quick 텍스트 입력 처리 및 유효성 검사기

텍스트 시각적 유형

Qt Quick 는 화면에 텍스트를 표시하기 위한 여러 유형을 제공합니다. ` Text ` 유형은 서식이 지정된 텍스트를 화면에 표시하고, ` TextEdit ` 유형은 여러 줄로 구성된 라인 편집 필드를 화면에 배치하며, ` TextInput `는 편집 가능한 단일 줄 필드를 화면에 배치합니다.

각 유형의 구체적인 기능과 속성에 대해 자세히 알아보려면 해당 문서를 참조하십시오.

입력 텍스트 유효성 검사

유효성 검사기 유형은 ` TextInput ` 객체의 유형과 형식을 강제 적용합니다.

DoubleValidator

정수가 아닌 숫자에 대한 유효성 검사기를 정의합니다.

IntValidator

정수 값에 대한 유효성 검사기를 정의합니다

RegularExpressionValidator

문자열 유효성 검사기를 제공합니다

Column {
    spacing: 10

    Text {
        text: "Enter a value from 0 to 2000"
    }
    TextInput {
        focus: true
        validator: IntValidator { bottom:0; top: 2000}
    }
}

유효성 검사기 유형은 ` TextInput`의 ` validator ` 속성에 바인딩됩니다.

Column {
    spacing: 10

    Text {
        text: "Which basket?"
    }
    TextInput {
        focus: true
        validator: RegularExpressionValidator { regularExpression: /fruit basket/ }
    }
}

스니펫에 있는 정규 표현식은 입력된 텍스트가 fruit basket 에 속하는 값일 때만 허용합니다.

Qml은 JavaScript 정규식을 구문 분석하는 반면, Qt의 QRegularExpression 클래스의 정규식은 Perl 정규식을 기반으로 한다는 점에 유의하십시오.

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