このページについて

名前が変更された型

この警告カテゴリは、qmllint によって「[renamed-type] 」と表記されます。

型名の変更

何が起きたのか?

QT_QML_SOURCE_TYPENAMEまたは手動で記述された qmldir を通じて名前が変更された型が、エクスポートされていない名前で呼び出されました。

なぜ問題なのか?

1 つの型に複数の名前が存在することになり、コードが分かりにくくなります。名前が変更されたシングルトンは、エクスポートされていない名前を使用すると正しく動作せず、また、現在の QML モジュール外の QML ファイルでは、エクスポートされていない名前を使用することはできません。

例

# 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
}

この警告を解消するには、古い名前を新しい名前に置き換えてください:

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