<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Thank you all - the problem is probably solved!</p>
<p>@Fabrice Mousset:</p>
<p>
<blockquote type="cite">
<p class="MsoNormal"><span lang="EN-US">@</span></p>
<p class="MsoNormal"><span lang="EN-US">text: !!Controller ?
Controller.triedSteps : “”</span></p>
<span lang="EN-US">@</span></blockquote>
shows the content but prints out a "<span style=" color:#aa00aa;">ReferenceError:
Controller is not defined</span>". I'll yet have to try this
solution in 5.13.1 (see below), it sounds interesting and better
than the "typeof"-way!</p>
<p>@Grecko/Pierre-Yves Siret:</p>
<p>You are absolutely right. The best solution, of course, would be
to load the QML page <strong>after</strong> the contextProperty
is set to the engine. I can and will do that with my current and
future code, but I can't do that for my legacy code base. Your
syntax suggestion is ubercool, btw.! <br>
</p>
<p>@Ulf Hermann:</p>
<p>You were right, it actually *is* a bug. Or rather was: it has
apparently been fixed in 5.12.5 / 5.13.1. <br>
Sorry for not finding this before. <br>
It had been introduced with 5.12.0 and I have tested with 12.1 and
13.0 - bad luck :-)<br>
<br>
Here's the bug:<br>
<a class="moz-txt-link-freetext" href="https://bugreports.qt.io/browse/QTBUG-76796">https://bugreports.qt.io/browse/QTBUG-76796</a><br>
Here's the fix:<br>
<a class="moz-txt-link-freetext" href="https://codereview.qt-project.org/c/qt/qtdeclarative/+/266776">https://codereview.qt-project.org/c/qt/qtdeclarative/+/266776</a><br>
</p>
<p>I'll upgrade to 13.1, that should just work. I haven't yet tested
because of some difficulties with the upgrade, my maintenanceTool
does strange things - but that's another story (told on
<a class="moz-txt-link-freetext" href="https://forum.qt.io/topic/107881/maintenancetool-crashes">https://forum.qt.io/topic/107881/maintenancetool-crashes</a>).<br>
</p>
<p>Thank you for time, effort and creative input! <br>
</p>
<p>Sebastian<br>
</p>
<div class="moz-cite-prefix">Am 17.10.2019 um 14:25 schrieb Fabrice
Mousset | GEOCEPT GmbH:<br>
</div>
<blockquote type="cite"
cite="mid:AM0PR08MB4259420C65BD8EAEB5C88E8EEA6D0@AM0PR08MB4259.eurprd08.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Vorformatiert Zchn";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.HTMLVorformatiertZchn
{mso-style-name:"HTML Vorformatiert Zchn";
mso-style-priority:99;
mso-style-link:"HTML Vorformatiert";
font-family:Consolas;
color:black;}
span.E-MailFormatvorlage21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US">Hi
Sebastian,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-US">Can you try this (I preferred using !! to
verify if a variable is defined and not null):<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">@<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">text: !!Controller ?
Controller.triedSteps : “”<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">@<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-US">BR<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-US">Fabrice<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="color:windowtext;mso-fareast-language:EN-US"
lang="EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm
0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="color:windowtext">Von:</span></b><span
style="color:windowtext"> Interest
<a class="moz-txt-link-rfc2396E" href="mailto:interest-bounces@qt-project.org"><interest-bounces@qt-project.org></a>
<b>Im Auftrag von </b><a class="moz-txt-link-abbreviated" href="mailto:mail@herrdiel.de">mail@herrdiel.de</a><br>
<b>Gesendet:</b> Donnerstag, 17. Oktober 2019 12:41<br>
<b>An:</b> <a class="moz-txt-link-abbreviated" href="mailto:interest@qt-project.org">interest@qt-project.org</a><br>
<b>Betreff:</b> Re: [Interest] Binding based on typeof
doesn't work any more<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi again, <o:p></o:p></p>
<p>I've found a better (JavaScript-) workaround without a
dummy property:<o:p></o:p></p>
<p>@<o:p></o:p></p>
<p>text: { return ((Controller === "undefined" || !Controller)
? "" : Controller.triedSteps) }<o:p></o:p></p>
<p>@<o:p></o:p></p>
<div>
<p class="MsoNormal">But still: Why has the behavior been
(apparently) changed at all in the first place? Or is it a
bug after all?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">BR<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Sebastian<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Am 17.10.2019 um 09:20 schrieb <a
href="mailto:mail@herrdiel.de" moz-do-not-send="true">
mail@herrdiel.de</a>:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>Hi,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>I have a simple Label that has to show a property of a rootProperty, the latter not yet being created when the qml is loaded/created. Quite frequently I use this construct and it did work perfectly in older Qt versions (something before 12.1 - that's the earliest I have installed now):<o:p></o:p></pre>
<pre>@<o:p></o:p></pre>
<pre>//[main.qml, inside a Label]<o:p></o:p></pre>
<pre>text: typeof Controller === "undefined" ? "" : Controller.successfulSteps<o:p></o:p></pre>
<pre>@<o:p></o:p></pre>
<pre>Now this doesn't show anything anymore. The following workaround does show the desired result:<o:p></o:p></pre>
<pre>@<o:p></o:p></pre>
<pre>property string dummy: ""<o:p></o:p></pre>
<pre>text: dummy+(typeof Controller === "undefined" ? "" : Controller.successfulSteps)<o:p></o:p></pre>
<pre>@<o:p></o:p></pre>
<pre>This seems very hackish. Is there a better way to achieve this? Why has the behavior been (apparently) changed at all in the first place?<o:p></o:p></pre>
<pre>The Controller has been set as a root property after loading the QML page:<o:p></o:p></pre>
<pre>@<o:p></o:p></pre>
<pre>//[main.cpp]<o:p></o:p></pre>
<pre>QQmlApplicationEngine engine;<o:p></o:p></pre>
<pre>engine.load(QUrl(QStringLiteral("qrc:/main.qml")));<o:p></o:p></pre>
<pre>Controller controller(&engine);<o:p></o:p></pre>
<pre>engine.rootContext()->setContextProperty("Controller", QVariant::fromValue<Controller*>(&controller));<o:p></o:p></pre>
<pre>@<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>I've asked this in forum.qt.io before (<a href="https://forum.qt.io/topic/107828/binding-based-on-typeof-doesn-t-work-any-more" moz-do-not-send="true">https://forum.qt.io/topic/107828/binding-based-on-typeof-doesn-t-work-any-more</a>)<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>BR<o:p></o:p></pre>
<pre>Sebastian<o:p></o:p></pre>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.classintouch.de" moz-do-not-send="true">http://www.classintouch.de</a> - Tablet-Software für Lehrer<o:p></o:p></pre>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>Interest mailing list<o:p></o:p></pre>
<pre><a href="mailto:Interest@qt-project.org" moz-do-not-send="true">Interest@qt-project.org</a><o:p></o:p></pre>
<pre><a href="https://lists.qt-project.org/listinfo/interest" moz-do-not-send="true">https://lists.qt-project.org/listinfo/interest</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.classintouch.de" moz-do-not-send="true">http://www.classintouch.de</a> - Tablet-Software für Lehrer<o:p></o:p></pre>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.classintouch.de">http://www.classintouch.de</a> - Tablet-Software für Lehrer</pre>
</body>
</html>