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. [SOLVED] Displaying list of contacts on Symbian phone
QtWS25 Last Chance

[SOLVED] Displaying list of contacts on Symbian phone

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 3.2k 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.
  • S Offline
    S Offline
    strekazoid
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      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
      0
      • S Offline
        S Offline
        strekazoid
        wrote on last edited by
        #3

        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
        0
        • T Offline
          T Offline
          task_struct
          wrote on last edited by
          #4

          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
          0
          • S Offline
            S Offline
            strekazoid
            wrote on last edited by
            #5

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

            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