Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML errors on objects exposed to QML via root setContextProperty in 5.15.2
Forum Updated to NodeBB v4.3 + New Features

QML errors on objects exposed to QML via root setContextProperty in 5.15.2

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 4 Posters 605 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • VStevenPV Offline
    VStevenPV Offline
    VStevenP
    wrote on last edited by
    #1

    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;
    #endif

    QQmlApplicationEngine 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.

    VStevenPV 1 Reply Last reply
    0
    • VStevenPV VStevenP

      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;
      #endif

      QQmlApplicationEngine 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.

      VStevenPV Offline
      VStevenPV Offline
      VStevenP
      wrote on last edited by VStevenP
      #2

      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.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Wouldn't it be simpler to use the platform property ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • VStevenPV Offline
          VStevenPV Offline
          VStevenP
          wrote on last edited by
          #4

          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.

          J.HilkJ 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Can you complete your example so we can reproduce the issue ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • jeremy_kJ Offline
              jeremy_kJ Offline
              jeremy_k
              wrote on last edited by
              #6

              It would also help to have the text of any errors, and indications of what code appears to trigger them.

              Asking a question about code? http://eel.is/iso-c++/testcase/

              1 Reply Last reply
              0
              • VStevenPV VStevenP

                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.

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @VStevenP
                can you show the actual error message ?

                also, do you have DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 enabled or something like that ?
                IIRC setContextProptery was supposed to become DEPRECATED sometime in the future


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                0
                • VStevenPV Offline
                  VStevenPV Offline
                  VStevenP
                  wrote on last edited by
                  #8

                  I am not able to recreate the problem as described so I will mark the topic as Solved. Thanks for your input.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved