title: Undefined reference on a binding to id, Scoping rules
body: <p>I am trying to pass around an object required by some qml components. The problem is that I cannot reference this object without it saying its undefined.</p>
  
  <pre><code>Item {
      id: root
  
      property alias db: database // this works for some reason
  
      Database {
          id: database
          Component.onCompleted: {
              connect("sqlite3", "dbname=database.db")
              deleteTables();
              createTables();
          }
      }
  
      ContactImageProvider {
          id: contactImageProvider
          database: db // this works for some reason
          database: root.database // This would be undefined
          database: database // no loop detected but still null
      }
  }
  </code></pre>
  
  <p>So I am very very confused how I am supposed to be able to pass dependencies down though objects without the most confusing naming scheme ever. This could be anything BTW. Maybe I need a color in some control but want to pass it to another control as well. The whole scope name resolution documentation is very unclear. I can't make heads or tails what I'm supposed to be able to do.</p>
  
  <pre><code>Item {
      id: root
  
      property Database database: Database {
          id: database // if no id then this doesnt work
          Component.onCompleted: {
              connect("sqlite3", "dbname=database.db")
              deleteTables();
              createTables();
          }
      }
      property alias db: database
  
      ContactImageProvider {
          id: contactImageProvider
          database: db // this doesn't work. WHY? idk
          database: database // works if id is on
      }
  }
  </code></pre>
  
  <p>Also aliasing doesn't seem to work if I make it a property.</p>