I want to use listview in QML whose data model is com from c++,
how ever i get missed with the following two part of codes.

This first codes below fail to append and display data in QML.
and the simulator debug tells that file:///opt/loveNote/qml/loveNote/DocumentPage.qml:34: ReferenceError: Can't find variable: myModel
Code:
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

    AnimalModel model;
         model.addAnimal(Animal("Wolf", "Medium"));
         model.addAnimal(Animal("Polar bear", "Large"));
         model.addAnimal(Animal("Quoll", "Small"));
         model.addAnimal(Animal("A", "B"));
         model.addAnimal(Animal("b", "7"));
         model.addAnimal(Animal("V", "4"));
         model.addAnimal(Animal("D", "5"));
         model.addAnimal(Animal("G", "5"));
         model.addAnimal(Animal("K", "2"));
         model.addAnimal(Animal("S", "B"));
         model.addAnimal(Animal("Z", "U"));
         model.addAnimal(Animal("C", "0"));
         model.addAnimal(Animal("W", "O"));
         model.addAnimal(Animal("bear", "Lge"));

    QmlApplicationViewer viewer;

   //   QDeclarativeContext *ctxt = viewer.rootContext();
     //   ctxt->setContextProperty("myModel", &model);
   QDeclarativeView view;
     view.rootContext()->setContextProperty("myModel", &model);
     view.setSource(QUrl("/opt/loveNote/qml/loveNote/main.qml")); 
     view.show();


    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/loveNote/main.qml"));
    viewer.showExpanded();

    return app->exec();
}

The second part is correct
Code:
Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

    AnimalModel model;
         model.addAnimal(Animal("Wolf", "Medium"));
         model.addAnimal(Animal("Polar bear", "Large"));
         model.addAnimal(Animal("Quoll", "Small"));
         model.addAnimal(Animal("A", "B"));
         model.addAnimal(Animal("b", "7"));
         model.addAnimal(Animal("V", "4"));
         model.addAnimal(Animal("D", "5"));
         model.addAnimal(Animal("G", "5"));
         model.addAnimal(Animal("K", "2"));
         model.addAnimal(Animal("S", "B"));
         model.addAnimal(Animal("Z", "U"));
         model.addAnimal(Animal("C", "0"));
         model.addAnimal(Animal("W", "O"));
         model.addAnimal(Animal("bear", "Lge"));


    QmlApplicationViewer viewer;

     QDeclarativeContext *ctxt = viewer.rootContext();
       ctxt->setContextProperty("myModel", &model);
/*
QDeclarativeView view;
     view.rootContext()->setContextProperty("myModel", &model);
     view.setSource(QUrl("/opt/loveNote/qml/loveNote/main.qml"));    //
     view.show();
*/


    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/loveNote/main.qml"));
    viewer.showExpanded();

    return app->exec();
}
And the second part successfuly display data in listview in my QML

my Listview codes here
Code:
  ListView{
        id:docListView;
        //anchors.bottomMargin: 5
        anchors.topMargin: 0

        objectName: "docView";
        anchors.top: pageTitle.bottom;
        anchors.left: parent.left;
        anchors.right: parent.right;
        anchors.bottom: parent.bottom;
        clip:true;
        model:myModel

        delegate:
            Rectangle{
            width:480;
            height:80;
            Text {
                text: "Document: " + title + ", " + subtext
               font.pointSize: 15
            }

        }

 }
What my main problem is how to dynamically append model data from c++ to ListView successfully.
Could anyone tell me how to do it?
I dont want to append data in the main function like this above.
I want to make it in a class ,when i call the class 's function i can apend data to ListView.