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

2019-10-18 Thread m...@herrdiel.de
Thank you all - the problem is probably solved!

@Fabrice Mousset:

> @
>
> text: !!Controller ?  Controller.triedSteps : “”
>
> @
shows the content but prints out a "ReferenceError: Controller is not
defined". I'll yet have to try this solution in 5.13.1 (see below), it
sounds interesting and better than the "typeof"-way!

@Grecko/Pierre-Yves Siret:

You are absolutely right. The best solution, of course, would be to load
the QML page *after* 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.!

@Ulf Hermann:

You were right, it actually *is* a bug. Or rather was:  it has
apparently been fixed in 5.12.5 / 5.13.1. 
Sorry for not finding this before.
It had been introduced with 5.12.0 and I have tested with 12.1 and 13.0
- bad luck :-)

Here's the bug:
https://bugreports.qt.io/browse/QTBUG-76796
Here's the fix:
https://codereview.qt-project.org/c/qt/qtdeclarative/+/266776

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
https://forum.qt.io/topic/107881/maintenancetool-crashes).

Thank you for time, effort and creative input!

Sebastian

Am 17.10.2019 um 14:25 schrieb Fabrice Mousset | GEOCEPT GmbH:
>
> 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  *Im Auftrag von
> *m...@herrdiel.de
> *Gesendet:* Donnerstag, 17. Oktober 2019 12:41
> *An:* interest@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 m...@herrdiel.de <mailto:m...@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.rootContext()->setContextProperty("Controller", 
> QVariant::fromValue());
>
> @
>
>  
>
> 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@qt-project.org <mailto:Interest@qt-project.org>
>
> https://lists.qt-project.org/listinfo/interest
>
> -- 
> http://www.classintouch.de - Tablet-Software für Lehrer

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

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


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

2019-10-18 Thread Pierre-Yves Siret
Can't you do the load after the setContextProperty?
That is what is usually done.

Your problem is a usecase for the suggestion I did there :
https://bugreports.qt.io/browse/QTBUG-77926
The code would then become :

Controller?.successfulSteps ?? ""


Le jeu. 17 oct. 2019 à 09:22,  a écrit :

> 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.rootContext()->setContextProperty("Controller", 
> QVariant::fromValue());
> @
>
> 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@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


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

2019-10-17 Thread Fabrice Mousset | GEOCEPT GmbH
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  Im Auftrag von m...@herrdiel.de
Gesendet: Donnerstag, 17. Oktober 2019 12:41
An: interest@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 m...@herrdiel.de<mailto:m...@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.rootContext()->setContextProperty("Controller", 
QVariant::fromValue());

@



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@qt-project.org<mailto:Interest@qt-project.org>

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

--

http://www.classintouch.de - Tablet-Software für Lehrer
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


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

2019-10-17 Thread Ulf Hermann
> But still: Why has the behavior been (apparently) changed at all in the 
> first place? Or is it a bug after all?

It does sound like a bug. Can you please open a bug report at 
https://bugreports.qt.io ? I would like to know

* What is the last version of Qt your example worked correctly with?

* What version of Qt broke it?

* What is the value of "typeof Controller" in the case where it should 
show the empty string and in the case where it should show the actual 
value for the good and for the bad version of Qt.

* What type is Controller.successfulSteps

* If Controller.successfulSteps is an integer, does the following work?
text: typeof Controller === "undefined" ? 0 : Controller.successfulSteps

br,
Ulf
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


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

2019-10-17 Thread mail
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 m...@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.rootContext()->setContextProperty("Controller", 
> QVariant::fromValue());
> @
>
> 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@qt-project.org
> https://lists.qt-project.org/listinfo/interest

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

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest