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. How to ignore properties that doesn't exist in Binding?
Qt 6.11 is out! See what's new in the release blog

How to ignore properties that doesn't exist in Binding?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 181 Views
  • 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.
  • K Offline
    K Offline
    Kamichanw
    wrote on last edited by
    #1

    I'm binding some properties to Loader.item.

    Loader {
        id: loader
        sourceComponent: comp
        Binding {
            target: loader.item
            property: "prop"
            value: 1
            when: loader.status === Loader.Ready
        }
    }
    

    If loader.item doesn't has prop, then the Binding should do nothing, otherwise, pass the value to loader.item. Note that you can't do like

    Binding {
            ...
            when: loader.status === Loader.Ready && loader.item.prop !== undefined
    }
    

    Because you can't assume that the value of loader.item.prop is not undefined.

    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