Unsolved File is not defined.
-
This class looks great. This is the c++ claas. If u want to see this class at qml side, it needs to be registered to qml using qmlregistertype etc methods. Looks like your class is not exposed to qml. Please check and if not please do so. Search in Google or qt assistant for how to expose c++ class to qml.
-
I have registered to qml using qmlregistertype method and included it inside my qml file as follows. But it gives following errors when i build.
inside my main.cpp file
qmlRegisterType <Info>("NT.Cpp",1,0, "Info");
inside my Icons.qml file it is included as
import NT.Cpp 1.0
But many errors appear as follows:
/opt/Qt/5.6.3/gcc_64/include/QtQml/qqmlprivate.h:93: error: within this context class QQmlElement : public T ^ /Info.h:98: error: ‘Info::Info()’ is private Info(); ^ /opt/Qt/5.6.3/gcc_64/include/QtQml/qqmlprivate.h:93: ‘QQmlPrivate::QQmlElement<Info>::QQmlElement()’ is implicitly deleted because the default definition would be ill-formed: class QQmlElement : public T ^
-
Looks like you have private constructor in Info class. Can you show the info.h file ? Above post only has implementation file.
-
Yes it looks like a private constructor, and with a
getInstance
method to get the singleton instance.Use
qmlRegisterSingletonType
and notqmlRegisterType
. If you use this instance in c++ too, don't forget to set the object ownership (withsetObjectOwnership
) toQQmlEngine::CppOwnership
.