string QML Value Type
자유 형식 텍스트 문자열입니다. 더 보기...
상세 설명
string
유형은 따옴표로 묶인 자유 형식 텍스트 문자열을 나타냅니다(예: "Hello world!"). QML 언어는 기본적으로 이 값 유형을 제공합니다.
예제:
Text { text: "Hello world!" }
string
유형의 속성은 기본적으로 비어 있습니다.
문자열에는 문자열의 문자 수를 나타내는 length
속성이 있습니다.
문자열 값 유형은 C++ 유형 QString 에 의해 뒷받침됩니다. 이는 동일한 API의 대부분과 몇 가지 추가 메서드를 제공한다는 점에서 JavaScript 문자열 기본 유형을 확장합니다. 예를 들어, QML 문자열 값 유형 메서드 arg()
는 값 대체를 지원합니다:
var message = "There are %1 items" var count = 20 console.log(message.arg(count))
위의 예는 "항목이 20개 있습니다"를 출력합니다.
QML 문자열 값 유형은 템플릿(문자열) 리터럴, 문자열 보간, 여러 줄 문자열 및 문자열에 대한 반복과 같은 대부분의 ECMAScript 문자열 기능을 지원합니다.
일반적으로 QML 문자열은 string.includes()
, string.startsWith()
, string.endsWith()
을 사용한 포함 여부 확인, string.repeats()
을 사용한 문자열 반복, string.slice()
및 string.split()
을 사용한 조각화 및 분할을 포함하여 대부분의 JavaScript 문자열 메서드를 지원합니다.
지원하는 ECMAScript QML 버전에 대한 자세한 내용은 JavaScript 호스트 환경을 참조하십시오.
자바스크립트 문자열 메서드에 대한 자세한 내용은 mdn 자바스크립트 문자열을 참조하십시오 .
C++와 통합할 때 C++에서 QML로 전달된 QString 값은 자동으로 string
값으로 변환되며, 그 반대의 경우도 마찬가지입니다.
QML 값 유형 및 ECMAScript 언어 사양도참조하세요 .
© 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.