StringLiterals Namespace

Qt::Literals::StringLiterals

The StringLiterals namespace declares string literal operators for Qt types. More...

Header: #include <StringLiterals>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

Functions

QLatin1Char operator""_L1(char ch)

Detailed Description

The inline Qt::Literals::StringLiterals namespace declares string literal operators for Qt types. Because both Literals and StringLiterals namespaces are declared as inline, the symbols from this namespace can be accessed by adding one of the following to your code:

 // Makes visible only the literal operators declared in StringLiterals
 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;

Function Documentation

[since 6.4] QLatin1Char operator""_L1(char ch)

Literal operator that creates a QLatin1Char out of ch.

The following code creates a QLatin1Char:

 using namespace Qt::Literals::StringLiterals;

 auto ch = 'a'_L1;

This function was introduced in Qt 6.4.

See also Qt::Literals::StringLiterals.