Qt::Literals::StringLiterals Namespace
namespace Qt::Literals::StringLiteralsStringLiterals 네임스페이스는 Qt 문자열 유형에 대한 리터럴 연산자를 선언합니다. 더 보기...
| 헤더: | #include <QString> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
기능
(since 6.4) QLatin1Char | operator""_L1(char ch) |
(since 6.4) QLatin1StringView | operator""_L1(const char *str, size_t size) |
(since 6.4) QByteArray | operator""_ba(const char *str, size_t size) |
(since 6.4) QString | operator""_s(const char16_t *str, size_t size) |
상세 설명
인라인 Qt::Literals::StringLiterals 네임스페이스는 Qt 문자열 유형에 대한 리터럴 연산자를 선언합니다. Literals 및 StringLiterals 네임스페이스 모두 인라인으로 선언되어 있으므로, 이 네임스페이스의 심볼에 접근하려면 코드에 다음 중 하나를 추가하면 됩니다:
// Makes visible only the literal operators declared in StringLiterals
using namespace Qt::StringLiterals;
// same, but needlessly verbose:
using namespace Qt::Literals::StringLiterals;
// Makes visible literal operators declared in all inline namespaces
// inside Literals
using namespace Qt::Literals;
// Makes visible all symbols (including all literal operators) declared
// in the Qt namespace
using namespace Qt;후자의 방법은 Qt XML이 Qt::Literals 내의 다른 네임스페이스에 충돌하는 연산자를 추가할 경우, 원하는 리터럴 연산자를 선택할 수 없게 되므로 권장되지 않습니다.
함수 문서
[constexpr noexcept, since 6.4] QLatin1Char operator""_L1(char ch)
ch 를 사용하여 QLatin1Char 을 생성하는 리터럴 연산자입니다.
다음 코드는 ` QLatin1Char` 객체를 생성합니다:
using namespace Qt::StringLiterals;
auto ch = 'a'_L1;이 함수는 Qt 6.4에서 도입되었습니다.
Qt::Literals::StringLiterals도 참조하십시오 .
[constexpr noexcept, since 6.4] QLatin1StringView operator""_L1(const char *str, size_t size)
문자열 리터럴 str 의 처음 size 개 문자를 사용하여 QLatin1StringView 를 생성하는 리터럴 연산자입니다.
다음 코드는 ` QLatin1StringView` 객체를 생성합니다:
using namespace Qt::StringLiterals;
auto str = "hello"_L1;이 함수는 Qt 6.4에서 도입되었습니다.
Qt::Literals::StringLiterals도 참조하십시오 .
[noexcept, since 6.4] QByteArray operator""_ba(const char *str, size_t size)
문자열 리터럴 str 의 처음 size 자를 사용하여 리터럴 객체( QByteArray )를 생성하는 리터럴 연산자입니다.
QByteArray 는 컴파일 시점에 생성되며, 생성된 문자열 데이터는 컴파일된 객체 파일의 읽기 전용 세그먼트에 저장됩니다. 중복된 리터럴은 동일한 읽기 전용 메모리를 공유할 수 있습니다. 이 기능은 QByteArrayLiteral 와 상호 교환 가능하지만, 코드에 많은 문자열 리터럴이 존재할 때 입력 작업을 줄여줍니다.
다음 코드는 ` QByteArray`를 생성합니다:
using namespace Qt::StringLiterals;
auto str = "hello"_ba;이 함수는 Qt 6.4에서 도입되었습니다.
Qt::Literals::StringLiterals도 참조하십시오 .
[noexcept, since 6.4] QString operator""_s(const char16_t *str, size_t size)
char16_t 문자열 리터럴 str 의 처음 size 자에서 QString 를 생성하는 리터럴 연산자입니다.
QString 는 컴파일 시점에 생성되며, 생성된 문자열 데이터는 컴파일된 객체 파일의 읽기 전용 세그먼트에 저장됩니다. 중복된 리터럴은 동일한 읽기 전용 메모리를 공유할 수 있습니다. 이 기능은 QStringLiteral 와 상호 교환 가능하지만, 코드에 많은 문자열 리터럴이 존재할 때 입력 작업을 줄여줍니다.
다음 코드는 ` QString`를 생성합니다:
using namespace Qt::StringLiterals;
auto str = u"hello"_s;이 함수는 Qt 6.4에서 도입되었습니다.
Qt::Literals::StringLiterals도 참조하십시오 .
© 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.