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. Detaching Q_Property before QML Component has been destroying.
Forum Updated to NodeBB v4.3 + New Features

Detaching Q_Property before QML Component has been destroying.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 917 Views 1 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.
  • RequR Offline
    RequR Offline
    Requ
    wrote on last edited by Requ
    #1

    I got the Qml property which value is base on value passed from backend via reading Q_Property:

    property bool isFullScreen: System.Fullscreen
    

    Everythis worked fine, until I was needed to upgrade project to 5.14.2. Now when I'm closing application I got error:

    qrc:/qml/main.qml:13: TypeError: Cannot read property 'Fullscreen' of null
    

    No I'm trying to figure out how can if thats happen. I was trying to use Component.onDestruction , but it is emited after backend has been detached from qml front.

    Also I was trying this:

    property bool isFullScreen: 
    { 
     if (Component.status === Component.Ready)
          return System.Fullscreen 
     else
        return false
    }
    

    But the Component is binding only to false

    Any idea?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Your backend gets destroyed before QML does. The solution is usually to rearrange how you initialise things in your main.cpp. Make sure backend outlives the engine and you won't see these errors (btw. they are completely harmless).

      (Z(:^

      1 Reply Last reply
      0
      • RequR Offline
        RequR Offline
        Requ
        wrote on last edited by
        #3

        Hi @sierdzio I was thinking about it but not sure how to do that.

        Currently I just have the Connection between QApplication signal and my backend slot to clean befor quiting the App.

        I was trying to add

        QObject::connect(&app, &QApplication::aboutToQuit, [&engine, &system] {  engine.quit(); system.disconnect(); )};
        

        But it doesn't change anything. I guess there should be a method to stop engine but can't find in docs https://doc.qt.io/qt-5/qqmlapplicationengine.html

        Am I doing something wrong or maybe you know how the enginge should be stopped?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          You can parent your QObjects to QML engine and Qt will clean it up for you.

          QQmlEngine engine;
          So something like: auto system = new System(&engine);
          engine.rootContext()->setContextProperty("System",  system);
          

          (Z(:^

          1 Reply Last reply
          0
          • RequR Offline
            RequR Offline
            Requ
            wrote on last edited by
            #5

            @sierdzio Hmm.. that's how I connected them and somehow from 5.14.x this isn't working correctly.

            QQmlApplicationEngine engine;
            engine.rootContext()->setContextProperty("theSystem", integrator->system());
            
            
            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              Yeah, but where is that integrator created? What manages it's lifetime?

              (Z(:^

              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