このページでは

Qt::Literals Namespace

namespace Qt::Literals

「Literals」インライン名前空間は、Qt 型用のリテラル演算子を宣言します。詳細...

ヘッダー: #include <QString>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

名前空間

namespace StringLiterals

詳細な説明

名前空間

namespace Literals::StringLiterals

インラインの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 内の異なる名前空間に競合する演算子を追加した場合、どのリテラル演算子を使用するかを指定できなくなるためです。

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