Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
6.5
Description
I had a type which I had copied from elsewhere and had forgotten to remove its constructor:
class ComponentCreator : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON Q_MOC_INCLUDE(<QtQml/qqmlcomponent.h>) public: ComponentCreator(QQmlEngine *engine); Q_INVOKABLE QQmlComponent *createComponent(const QByteArray &data); };
Attemping to use this in QML resulted in a vague warning:
QWARN : tst_controls::Basic::StackView::test_componentCreatedFromCpp() file:///home/mitch/dev/qt-dev/qtdeclarative/tests/auto/quickcontrols2/controls/data/tst_stackview.qml:1555: TypeError: Cannot call method 'createComponent' of undefined
It would be easier for users to understand what was going wrong if there was a specific error message. For example:
"ComponentCreator cannot be exposed to QML because it has no default constructor."
Attachments
Issue Links
- duplicates
-
QTBUG-104899 QML(_NAMED)_ELEMENT should generate a clear error if the type in not default constructible
- Closed
- relates to
-
QTBUG-87834 Provide a more detailed error message when a C++ type that's exposed to QML cannot be created
- Closed