Details
-
Bug
-
Resolution: Won't Do
-
P2: Important
-
None
-
5.15.4
-
None
Description
Documentation for Q_ENUM_NS: https://doc.qt.io/qt-5/qobject.html#Q_ENUM_NS tells that:
> Registered enumerations are automatically registered also to the Qt meta type system,
> making them known to QMetaType without the need to use Q_DECLARE_METATYPE().
But code bellow prints:
```
qrc:/main.qml:15: Error: Unknown method parameter type: Data::DType
```
With un-commented Q_DECLARE_METATYPE the error disappears.
Also with Qt6 (recent dev branch) all works fine without "Q_DECLARE_METATYPE",
so this is specific only for Qt 5.15.4
#include <QQuickItem> namespace Data { Q_NAMESPACE QML_ELEMENT enum DType { A, B }; Q_ENUM_NS(DType) } // namespace Data //Q_DECLARE_METATYPE(Data::DType) class MyItem : public QQuickItem { private: Q_OBJECT QML_ELEMENT public: MyItem(); Q_INVOKABLE void setDType(Data::DType) {} };
import QtQuick 2.15 import QtQuick.Window 2.15 import example.mylib 1.0 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Component.onCompleted: { myItem.setDType(0); } MyItem { id: myItem } }