[Interest] Binding based on typeof doesn't work any more

Fabrice Mousset | GEOCEPT GmbH fabrice.mousset at geocept.com
Thu Oct 17 14:25:18 CEST 2019


Hi Sebastian,

Can you try this (I preferred using !! to verify if a variable is defined and not null):
@
text: !!Controller ?  Controller.triedSteps : “”
@

BR

Fabrice

Von: Interest <interest-bounces at qt-project.org> Im Auftrag von mail at herrdiel.de
Gesendet: Donnerstag, 17. Oktober 2019 12:41
An: interest at qt-project.org
Betreff: Re: [Interest] Binding based on typeof doesn't work any more


Hi again,

I've found a better (JavaScript-) workaround without a dummy property:

@

text: { return ((Controller === "undefined" || !Controller) ? "" : Controller.triedSteps) }

@
But still: Why has the behavior been (apparently) changed at all in the first place? Or is it a bug after all?

BR
Sebastian

Am 17.10.2019 um 09:20 schrieb mail at herrdiel.de<mailto:mail at herrdiel.de>:

Hi,



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):

@

//[main.qml, inside a Label]

text: typeof Controller === "undefined" ? "" : Controller.successfulSteps

@

Now this doesn't show anything anymore. The following workaround does show the desired result:

@

property string dummy: ""

text: dummy+(typeof Controller === "undefined" ? "" : Controller.successfulSteps)

@

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?

The Controller has been set as a root property after loading the QML page:

@

//[main.cpp]

QQmlApplicationEngine engine;

engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

Controller controller(&engine);

engine.rootContext()->setContextProperty("Controller", QVariant::fromValue<Controller*>(&controller));

@



I've asked this in forum.qt.io before (https://forum.qt.io/topic/107828/binding-based-on-typeof-doesn-t-work-any-more)



BR

Sebastian

--

http://www.classintouch.de - Tablet-Software für Lehrer



_______________________________________________

Interest mailing list

Interest at qt-project.org<mailto:Interest at qt-project.org>

https://lists.qt-project.org/listinfo/interest

--

http://www.classintouch.de - Tablet-Software für Lehrer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20191017/41349a23/attachment.html>


More information about the Interest mailing list