[Qbs] Accessing properties from a parent project
Jochen Becher
jochen_becher at gmx.de
Thu Jul 10 14:11:08 CEST 2025
I was able to create a small (not necessary minimal) example. Please
see the attached zip file.
It is much more complex than my original minimal code. The main aspect
seems to me a change in qbs 3.0.0:
SubProject { filePath: "MyApp.qbs" }
seems to set parent differently than in the past. If I insert the
content of MyApps.qbs which is a fairly simple CppApplication product
then it works. The module "mymodule" also seems to be important to see
the issue.
Regards, Jochen
Am Donnerstag, dem 10.07.2025 um 13:16 +0200 schrieb Richard Weickelt:
> 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
>
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> https://lists.qt-project.org/listinfo/qbs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qbs3test.zip
Type: application/zip
Size: 3047 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20250710/d3a0ed6b/attachment.zip>
More information about the Qbs
mailing list