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

Why does Qt.createComponent() fail when loading a local QML file?

↗ Original Qt Forum discussion

A Qt Forum user could create QML components from qrc resources but received a network-style error when trying to load a local file dynamically.

qml
var url = Qt.resolvedUrl("E:/QT/abc/my.qml")var comp = Qt.createComponent(url)
0 votes

1 Answer

DP
Dheerendra V Purohit
September 11, 2026 • Independent answer
✓ Accepted
Dheerendra suggested resolving the local Windows path as a proper file URL. The thread was solved after using the file:/// prefix.
qml
var url = Qt.resolvedUrl("file:///E:/QT/abc/my.qml")var comp = Qt.createComponent(url)
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