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.?