Skip to content
  • 0 Votes
    2 Posts
    179 Views
    sierdzioS

    Yes, you can put any QObject-subclass in as a property (use pointers). Also works with Q_GADGETs.

  • 0 Votes
    2 Posts
    374 Views
    sierdzioS

    Please file a suggestion to fix the docs to Qt bugtracker.

    I suspect (just a guess) that if you defined your object as alias or QtObject it would have worked. It's very possible that QML engine assumes var to be "plain" JavaScript that does not need any further binding checks.

  • 0 Votes
    2 Posts
    994 Views
    T

    I just ran into this issue myself, and I have a solution. I know this is an old topic, but since this was pretty much the only thing I could find on the internet about this problem, hopefully this can help someone else.

    In order to bind to a property of the nested QtObject props from the of component A, props needs to be a type of component that is known within the scope where it's properties are being accessed.

    To fix the code above, create a new file for the props Component:

    //Props.qml import QtQml 2.0 QtObject { property color mainColor }

    Now update the A component to use the Props component:

    //A.qml import QtQuick 2.0 import QtQml 2.0 Rectangle { property Props props: Props { mainColor: "blue" } color: props.mainColor }

    A few things to note here from my testing:
    If you were to now add a new property to the instance of Props in A.qml above, and try to bind a value to that , it would fail, because in the outside scope, that new property is not a known property of the Props type.
    Similarly, if you were to declare A.props as property QtObject props: Props { ... } then binding to mainColor would fail because mainColor is not a property of QtObject, and props is being exposed as a QtObject (the base class).

    It appears that the property resolution for binding to a nested property is not able to infer additional properties added to an instance of an object, and can only be bound to known properties of the type being exposed.

  • 0 Votes
    8 Posts
    4k Views
    dheerendraD

    ok. Let us look at like this. Instead of web view, put the Rectangle{}
    Try to show & hide the rectangle instead of web-view. Till me whether it works or not.
    Try something like this
    OffLine_Pages.qml

    Pane{ id: view property string local_url : "" property string pid : "" property alias vis: web.visible Rectangle{ id : web width: 200;height: 200;color: "red" visible: false } }
  • 0 Votes
    1 Posts
    420 Views
    No one has replied