How to display errors for Loader?



  • I have a loader defined and would like to display a Text element with an error text if the loader failed to load a source.
    @
    Loader {
    id: view;
    asynchronous: true;
    visible: status == Loader.Ready
    clip: true;
    focus: true;

      width: main.width - sidePanel.width;
      height: parent.height;
      z: 1;
    
      Text {
        visible: view.status == Loader.Error
        text: "Could not load" + view.source
      }
    }
    

    @

    The text is not visible though.


  • Moderators

    You need to anchor your Text element.

    Also, make sure Loader is working as you expect with:
    @
    id: view
    // ...
    onStatusChanged: {
    console.log("Loader status changed to " + status);
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.