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

How can a value be passed from main.qml to another QML component?

↗ Original Qt Forum discussion

A Qt Forum user had a reusable QML component and wanted to change an exposed value from main.qml.

qml
Comp1 {    id: obj}
0 votes

1 Answer

DP
Dheerendra V Purohit
September 11, 2026 • Independent answer
✓ Accepted
Dheerendra showed that main.qml can set an exposed property on the child component instance directly. The child should expose the value as a property, and the parent can assign or update it through the component id.
qml
Comp1 {    id: obj    aString: "Venki"} obj.aString = "PthinkS"
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