Contact model not working



  • Hello, i have coded a simple contact page, that shows all contacts with their name (and a selection dialog for the phone numbers).
    It works fine on the Simulator and the last time i tested it on phone with the first Qt SDK Version that was released, it worked also.

    @
    import Qt 4.7

    import QtMobility.contacts 1.1
    import com.nokia.symbian 1.0

    Page {
    id: contactsPage

    signal numberSelected(string phoneNumber)
    
    width: 360
    height: 640
    
    Text {
        id: title
        text: "Contacts"
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: parent.top
        anchors.topMargin: 6
        color: platformStyle.colorNormalLight
    }
    
    ListView {
        id: mainList
        anchors.left: parent.left
        anchors.leftMargin: 6
        anchors.right: parent.right
        anchors.rightMargin: 6
        anchors.top: title.bottom
        anchors.bottom: parent.bottom
        anchors.topMargin: 6
        cacheBuffer: 200
        highlightFollowsCurrentItem: true
    
        snapMode: ListView.SnapOneItem
        model: contactModel.contacts
        delegate: listDelegate
    
        ContactModel {
            id: contactModel
    
            sortOrders: [
                SortOrder {
                    detail: ContactDetail.Name
                    field: Name.LastName
                    direction: Qt.AscendingOrder
                },
                SortOrder {
                    detail: ContactDetail.Name
                    field: Name.FirstName
                    direction: Qt.AscendingOrder
                }
            ]
        }
    
        Component {
            id: listDelegate
    
            ListItem {
                id: contactItem
                subItemIndicator: true
    
                ListItemText {
                    id: nameItem
                    mode: contactItem.mode
                    role: "Title"
                    text: displayLabel
                }
    
                SelectionDialog {
                    id: numberSelection
                    titleText: "Choose a phone number:"
                    model: phoneNumbers
    
                    delegate:
                        MenuItem {
                            id: numberItem
                            text: number
    
                            onClicked: {
                                numberSelected(text);
                                numberSelection.accept();
                            }
                        }
                }
    
                onClicked: numberSelection.open()
            }
        }
    
        ScrollDecorator {
            flickableItem: mainList
        }
    
    }
    

    }
    @

    Now i have rewritten my code to use the new symbian qml components, and now the contacts are not shown anymore on the device. Also there are no errors. On the simulator it still works without problems.

    It looked like a capabilities problem, but i don't know whats missing from my .pro file:

    @symbian:TARGET.CAPABILITY += NetworkServices
    WriteUserData
    ReadUserData
    LocalServices
    UserEnvironment
    WriteDeviceData
    ReadDeviceData

    CONFIG += qt mobility
    MOBILITY += contacts messaging
    QT += xml network
    @



  • I tried to use a other ContactManager:
    @
    ContactModel {
    ...
    manager: "symbiansim"
    ...
    }
    @
    And now all my contacts that are stored on my SIM are shown. But manager "symbian" shows no contacts. It is also no QML specific problem. I tried to retrieve contacts in my main.cpp:
    @
    QContactManager contactManager;
    qDebug() << contactManager.availableManagers();
    QList<QContact> contacts = contactManager.contacts();
    @
    But the "contacts" list is empty.

    I have no idea what is wrong...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.