Results 1 to 6 of 6

Thread: QML Contact model search crash

  1. #1
    Join Date
    Oct 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy QML Contact model search crash

    What I have is a listview, to show list of contacts. There is one model for that listview, a search box and also a label. Whenever the user enters text in the search box, to filter the contacts based on the text typed in the search box.


    Here is my code

    Qt Code:
    1. // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    2. import QtQuick 1.1
    3. import Qt 4.7
    4. import QtMobility.contacts 1.1
    5.  
    6. Rectangle {
    7. property QtObject blah: con
    8. width: 360
    9. height: 640
    10.  
    11. ListView
    12. {
    13. anchors.top:searchbox.bottom
    14.  
    15. height: parent.height
    16. width: parent.width
    17. id: _ListViews
    18.  
    19. model:ContactModel{
    20.  
    21. filter: DetailFilter {
    22.  
    23. id:filter
    24.  
    25. detail:ContactDetail.Name
    26.  
    27. field:Name.FirstName
    28.  
    29. value:searchbox.searchtext
    30. matchFlags:Filter.MatchStartsWith
    31.  
    32. }
    33. sortOrders: SortOrder{
    34. detail: ContactDetail.Name
    35. field:Name.FirstName
    36. direction: Qt.AscendingOrder
    37.  
    38. }
    39. }
    40.  
    41. delegate: Rectangle{
    42. width: parent.width
    43. height:50
    44. Item {
    45. Column{
    46.  
    47. Text {
    48. id: name
    49. text: model.contact.displayLabel
    50. }
    51. }
    52. }
    53.  
    54. }
    55. }
    56. SearchBox{
    57. id: searchbox
    58.  
    59. visible: true
    60.  
    61.  
    62. }
    63.  
    64.  
    65. }
    To copy to clipboard, switch view to plain text mode 


    whenever i type a letter i get the error
    TypeError: Result of expression 'model.contact' [undefined] is not an object.
    if there are no matches in the contact list the app crashes



    Now I need to display nothing found in the list view, when there are no matches in the list. How to achieve that.?

  2. #2
    Join Date
    Oct 2012
    Location
    Chennai, India
    Posts
    3
    Platforms
    Symbian S60

    Default Re: QML Contact model search crash

    I have a similar issue like Vaibhav.sood15. I can filter contacts based on the text typed in the search box. But if there are no matches in the contact list the app crashes and terminates. I have posted a question with my code in stackoverflow. Here is the link. http://stackoverflow.com/questions/1...el-has-no-data
    Last edited by bkjoshua; 10th October 2012 at 06:54.

  3. #3
    Join Date
    Oct 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QML Contact model search crash

    Quote Originally Posted by bkjoshua View Post
    I have a similar issue like Vaibhav.sood15. I can filter contacts based on the text typed in the search box. But if there are no matches in the contact list the app crashes and terminates. I have posted a question with my code in stackoverflow. Here is the link. http://stackoverflow.com/questions/1...el-has-no-data
    Hi can you send me your complete proj so i can see if you are getting errors while filtering everytime or just once when the app crashes.

  4. #4
    Join Date
    Oct 2012
    Location
    Chennai, India
    Posts
    3
    Platforms
    Symbian S60

    Default Re: QML Contact model search crash

    Just hav a look at the stackoverflow link. I have pasted my whole code there. And yes, I can filter contacts everytime based on the text typed in the searchbox, without any errors. Only if there was no matches, the app crashes.

  5. #5
    Join Date
    Oct 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QML Contact model search crash

    Did you try it on the simulator or a real device coz mine crashes on the simulator not on a device

  6. #6
    Join Date
    Oct 2012
    Location
    Chennai, India
    Posts
    3
    Platforms
    Symbian S60

    Default Re: QML Contact model search crash

    I tried it with a Symbian belle device. ( Nokia N8 ).

Similar Threads

  1. Read Contact - Symbian ^3
    By fuoco66 in forum Qt Programming
    Replies: 5
    Last Post: 11th September 2011, 14:47
  2. How to create a contact group
    By loolz in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2011, 22:50
  3. How to create collapsing type contact list
    By The Storm in forum Qt Programming
    Replies: 38
    Last Post: 10th October 2009, 13:34
  4. How can I contact a DLL using Qt.
    By srohit24 in forum Qt Programming
    Replies: 3
    Last Post: 19th February 2009, 04:58
  5. Crash: using a dialog in a model
    By Brandybuck in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2006, 01:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.