[Qbs] Accessing properties from a parent project

Richard Weickelt richard at weickelt.de
Thu Jul 10 13:16:05 CEST 2025


Hi,

 > readonly property stringList onEmbedded: parent.onEmbedded

 > Project {
 > 	property bool mySetting: true
 >
 > 	Project {
 > 		property bool mySettings: parent.mySetting
 >                     ? parent.mySetting : false
 > 	}
 > }

This looks problematic. Qbs flattens nested and merges referenced project 
items during the evaluation process (see 
https://doc.qt.io/qbs/special-property-values.html#project). The 
documentation does not say it, but that's what Qbs does with project items 
under the hood AFAIK. If you define properties with the same name shadowing 
each other and you use parent in addition, you may observe unwanted side 
effects of the project merger. Maybe you get different results in different 
projects because the property is evaluated at different times during the 
resolve proces. For instance during early project evaluation, during probe 
resolving or during module loading in products.

I was under the impression that the special "parent" alias is only a relict 
from the QML parser and not guaranteed to work in Qbs. The same applies to 
"id". It's reserved for probes at the moment although it works in other 
cases too.

Could you live with a different solution? This would work:

Project {
     property bool mySetting: true
     Project {
         property bool myOtherSetting: project.mySetting
             ? project.mySetting : false
     }
}

Or if you explain what you want to achieve, we may find a different solution?

Richard



More information about the Qbs mailing list