Create Model for QML TreeView
问题 I'm trying to use QML TreeView Model. The example from Qt doesn't include how to create the model. I read this post and tried to use the code from @Tarod but the result is not what I expected. main.cpp #include <QGuiApplication> #include <QQmlApplicationEngine> #include "animalmodel.h" #include <qqmlcontext.h> #include <qqml.h> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); AnimalModel model; model.addAnimal("wolf", "Medium"); model.addAnimal("Bear", "Large");