In questa pagina

QQmlSA::PassManager Class

class QQmlSA::PassManager

È in grado di analizzare un elemento e i suoi elementi figli tramite cicli di analisi statica. Maggiori informazioni...

Intestazione: #include <qqmlsa.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
Stato: Anteprima tecnologica

Questa classe è in anteprima tecnologica ed è soggetta a modifiche.

Funzioni pubbliche

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)

Descrizione dettagliata

Documentazione delle funzioni membro

void PassManager::analyze(const QQmlSA::Element &root)

Esegue l'elemento che passa su root e su tutti i suoi elementi figli.

std::unordered_map<quint32, QQmlSA::Binding> PassManager::bindingsByLocation() const

Restituisce i collegamenti in base alla loro posizione di origine.

bool PassManager::hasImportedModule(QAnyStringView module) const

Restituisce ` true ` se il modulo denominato ` module ` è stato importato dal QML da analizzare, ` false ` in caso contrario.

Ciò può essere utilizzato per evitare la registrazione di un passaggio specifico per un determinato modulo.

if (passManager->hasImportedModule("QtPositioning"))
    passManager->registerElementPass(
       std::make_unique<PositioningPass>(passManager)
    );

Vedi anche registerPropertyPass() e registerElementPass().

bool PassManager::isCategoryEnabled(QQmlSA::LoggerWarningId category) const

Restituisce ` true ` se sono abilitati gli avvisi di ` category `, altrimenti ` false `.

void PassManager::registerElementPass(std::unique_ptr<QQmlSA::ElementPass> pass)

Registra un’analisi statica pass da eseguire su tutti gli elementi.

bool PassManager::registerPropertyPass(std::shared_ptr<QQmlSA::PropertyPass> pass, QAnyStringView moduleName, QAnyStringView typeName, QAnyStringView propertyName = QAnyStringView(), bool allowInheritance = true)

Registra un ciclo di analisi statica per le proprietà. L'pass verrà eseguito su ogni proprietà che corrisponda a moduleName, typeName e propertyName.

Omettendo l’ propertyName, questa fase verrà registrata per tutte le proprietà che corrispondono a typeName e moduleName.

Impostando allowInheritance su true, il filtro sul tipo accetterà anche i tipi derivati da typeName.

pass viene passato come std::shared_ptr per consentire il riutilizzo dello stesso passaggio su più elementi:

auto titleValiadorPass = std::make_shared<TitleValidatorPass>(manager);
manager->registerPropertyPass(titleValidatorPass,
                              "QtQuick", "Window", "title");
manager->registerPropertyPass(titleValidatorPass,
                              "QtQuick.Controls", "Dialog", "title");

Nota: l'esecuzione di passaggi di analisi su un numero eccessivo di elementi può risultare onerosa. Per questo motivo è generalmente consigliabile restringere l'insieme delle proprietà di un passaggio utilizzando ` moduleName`, ` typeName ` e ` propertyName`.

Restituisce true se il passaggio è stato aggiunto con successo, false in caso contrario. L’aggiunta di un passaggio fallisce quando il Element specificato da moduleName e typeName non esiste.

Vedi anche 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.