QQmlSA::PassManager Class
class QQmlSA::PassManager静的解析パスにより、要素とその子要素を解析できます。詳細...
| ヘッダー: | #include <qqmlsa.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlCompiler) target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler) |
| ステータス: | テクノロジープレビュー |
このクラスはテクノロジープレビュー段階にあり、変更される可能性があります。
パブリック関数
| void | analyze(const QQmlSA::Element &root) |
| std::unordered_map<quint32, QQmlSA::Binding> | bindingsByLocation() const |
| bool | hasImportedModule(QAnyStringView module) const |
| bool | isCategoryEnabled(QQmlSA::LoggerWarningId category) const |
| void | registerElementPass(std::unique_ptr<QQmlSA::ElementPass> pass) |
| bool | registerPropertyPass(std::shared_ptr<QQmlSA::PropertyPass> pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName = QAnyStringView(), bool allowInheritance = true) |
メンバー関数のドキュメント
void PassManager::analyze(const QQmlSA::Element &root)
要素がroot およびそのすべての子要素を通過する際に実行されます。
std::unordered_map<quint32, QQmlSA::Binding> PassManager::bindingsByLocation() const
ソースの位置に基づいてバインディングを返します。
bool PassManager::hasImportedModule(QAnyStringView module) const
解析対象のQMLによって、module という名前のモジュールがインポートされている場合はtrue を返し、そうでない場合はfalse を返します。
これを使用して、特定のモジュールに固有のパスの登録をスキップすることができます。
if (passManager->hasImportedModule("QtPositioning"))
passManager->registerElementPass(
std::make_unique<PositioningPass>(passManager)
);registerPropertyPass() およびregisterElementPass()も参照してください 。
bool PassManager::isCategoryEnabled(QQmlSA::LoggerWarningId category) const
category の警告が有効になっている場合は `true ` を返し、そうでない場合は `false ` を返します。
void PassManager::registerElementPass(std::unique_ptr<QQmlSA::ElementPass> pass)
すべての要素に対して静的解析pass を実行するように登録します。
bool PassManager::registerPropertyPass(std::shared_ptr<QQmlSA::PropertyPass> pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName = QAnyStringView(), bool allowInheritance = true)
プロパティに対する静的解析パスを登録します。pass は、moduleName 、typeName 、およびpropertyName に一致するすべてのプロパティに対して実行されます。
propertyName を省略すると、typeName およびmoduleName に一致するすべてのプロパティに対してこのパスが登録されます。
allowInheritance をtrue に設定すると、型によるフィルタリングにおいて、typeName から派生した型も受け入れられるようになります。
pass std::shared_ptr として渡されることで、複数の要素に対して同じパスを再利用できるようになります:
auto titleValiadorPass = std::make_shared<TitleValidatorPass>(manager);
manager->registerPropertyPass(titleValidatorPass,
"QtQuick", "Window", "title");
manager->registerPropertyPass(titleValidatorPass,
"QtQuick.Controls", "Dialog", "title");注: 分析パスを過度に多くの項目に対して実行すると 、処理負荷が高くなる可能性があります。そのため、一般的には `moduleName`、`typeName `、および `propertyName` を使用して、パスの対象となるプロパティのセットを絞り込むことが推奨されます。
パスの追加に成功した場合は `true ` を返し、失敗した場合は `false ` を返します。moduleName およびtypeName で指定された `Element ` が存在しない場合、パスの追加は失敗します。
PropertyPassも参照してください 。
© 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.