PthinKS PthinKS Developer Forum forum.pthinks.com C++ • Qt • QML Engineering Community
PthinKS Engineering Q&A
forum.pthinks.com
Close
QML

Why is a C++ class reported as undefined in QML?

↗ Original Qt Forum discussion

A developer had a QObject-based C++ class but QML could not see or instantiate it.

0 votes

1 Answer

DP
Dheerendra V Purohit
September 11, 2026 • Independent answer
✓ Accepted
Dheerendra explained that a C++ class must be exposed or registered before QML can use it. In the follow-up he also highlighted that a registered creatable type needs an accessible constructor.
cpp
qmlRegisterType<Info>("Company.Types", 1, 0, "Info");
0 replies
Continue the discussion under Dheerendra V Purohit's answer. This reply remains inside this answer thread.
Optional reply code

Answer this Question

Each person can post an independent answer. To discuss a specific answer, use Reply to this answer under that answer.

Explain your own solution first; add reusable code if needed.

Optional code solution