Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] Displaying list of contacts on Symbian phone

    QML and Qt Quick
    2
    5
    2879
    Loading More Posts
    • 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.
    • S
      strekazoid last edited by

      Trying to display list of contacts on Symbian Anna / Belle phone with this code:

      @import QtQuick 1.1
      import QtMobility.contacts 1.1

      ListView {
      width: 180; height: 200

       model: ContactModel {}
       delegate: Text {
           text: name + ": " + number
       }
      

      }@

      I'm getting "ReferenceError: Can't find variable: name" errors (and same for number) when running this on device. I sort of remember that this used to work. But not anymore. Wonder what might be wrong.

      1 Reply Last reply Reply Quote 0
      • T
        task_struct last edited by

        Hi,

        name is of type "Name":http://doc.qt.nokia.com/qtmobility/qml-name.html

        you should use, for example:

        @
        text: name.firstName + ": " + phoneNumber.number
        @

        "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

        • Linu...
        1 Reply Last reply Reply Quote 0
        • S
          strekazoid last edited by

          Good point. But still no luck:

          @Component {
          id: contactDelegate
          Item {
          width: 180; height: 40
          Column {
          Text { text: '<b>Name:</b> ' + name.firstName }
          Text { text: '<b>Number:</b> ' + phoneNumber.number }
          }
          }
          }

                   ListView {
                       anchors.fill: parent
                       model: ContactModel {}
                       delegate: contactDelegate
                       highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
                       focus: true
                   }@
          

          Output:

          [Qt Message] file:///C:/Private/2005be67/qml/ContactBook.qml:26: ReferenceError: Can't find variable: phoneNumber
          [Qt Message] file:///C:/Private/2005be67/qml/ContactBook.qml:25: ReferenceError: Can't find variable: name

          1 Reply Last reply Reply Quote 0
          • T
            task_struct last edited by

            I've used QtMobility.contacts only once and I don't remember well.

            See "this thread":http://developer.qt.nokia.com/forums/viewthread/11381 He uses @model: contactsmodel.contacts@

            I think that @contacts.name.firstName@ is also valid

            "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

            • Linu...
            1 Reply Last reply Reply Quote 0
            • S
              strekazoid last edited by

              Thanks, using contactsmodel.contacts as model solved the problem.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post