Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.5.1
-
Ubuntu 22
-
-
6ea6bbeb3 (dev)
Description
When trying to register non default constructible class derived from `QObject` as QML type, there's a warning during the registration: `<CLASS NAME> is neither a QObject, nor default- and copy-constructible, nor uncreatable. You should not use it as a QML type.`
Example of such class:
class MyObject: public QObject { Q_OBJECT QML_ELEMENT public: explicit MyObject(int value, QObject* parent = nullptr); };
According to the warning message such class should work without any warnings because it's derived from `QObject`.
I quickly looked at the code and according to this line https://github.com/qt/qtdeclarative/blob/6.5.1/src/qml/qml/qqmlprivate.h#L973 , if a class is not default constructible it does not even check latter conditions.
Why this is important because according to this comment https://github.com/qt/qtdeclarative/blob/6.5.1/src/qml/qml/qqml.h#L777 , this check will be replaced with static assert which will lead to the code that won't compile at all.
Is this a misleading warning message or a bad condition, or I misunderstood something?
Thanks!
P.S. I did not have such a warning in Qt 6.4.