QML errors on objects exposed to QML via root setContextProperty in 5.15.2
-
I get QML errors on objects exposed to QML via root setContextProperty in 5.15.2.
The problem doesn't occur for me in 5.12.10.
That said, the problem could be that I'm on SDK 11.1 and now on BigSur. I need to see if I can download the Xcode 10.15 SDK and retest it then follow up here..
In the meantime, if there is a Mac OS user who is on 5.15.2 and has SDK 10.15, it might be worth testing root setContextProperty to see if it errors out for you, that way I could report a bug if it's a real problem.
You'd need to try something like this in main.cpp:
#include <QQmlContext>
bool isMacOS;
#ifdef Q_OS_MACOS
isMacOS = true;
#else
isMacOS = false;
#endifQQmlApplicationEngine engine; QQmlContext *rootContext = engine.rootContext(); rootContext->setContextProperty("isMacOS", isMacOS);
then try to use isMacOS in main.qml or in a Javascript file imported in main.qml.
-
Please feel free to close this if needed, since it's not a help question, per se. I just thought I would ask here if anyone else sees the problem on 10.15 SDK, since I'm not sure how easy it's going to be for me to get it installed in Big Sur.
-
Hi,
Wouldn't it be simpler to use the platform property ?
-
In regards to OS detection, you are correct. Yet the code I provided is "just for example" about how to generate the QML errors on Qt 5.15.2.
My actual problem code is more complex than that, where I instantiate objects of 2 custom Qt classes and expose them to QML via root setContextProperty, and I get QML errors in 5.15.2.
Thanks for the comment though - it is helpful for my future programming.
-
Can you complete your example so we can reproduce the issue ?
-