Tipo rinominato
Questa categoria di avviso viene indicata da qmllint come " [renamed-type] ".
Tipo rinominato
Cosa è successo?
Un tipo, che è stato rinominato tramite QT_QML_SOURCE_TYPENAME o tramite un qmldir scritto manualmente, è stato chiamato con il suo nome non esportato.
Perché è un problema?
Ciò rende il codice confuso, poiché un singolo tipo ha ora più di un nome. I singleton rinominati non funzioneranno correttamente se si utilizza il loro nome non esportato, e il nome non esportato non può essere utilizzato dai file QML al di fuori del modulo QML corrente.
Esempio
# CMakeLists.txt
set_source_files_properties(Tree.qml PROPERTIES QT_QML_SOURCE_TYPENAME BinaryTree)
qt_add_qml_module(MyModule
URI MyModule
QML_FILES Tree.qml
)// Tree.qml
import QtQml
Item {
property Tree left // uses old name - not ok
property Tree right // uses old name - not ok
}Per risolvere questo avviso, sostituisci il vecchio nome con quello nuovo:
// Tree.qml
import QtQml
Item {
property BinaryTree left // uses new name - ok
property BinaryTree right // uses new name - ok
}© 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.