问个QML数据暴露的问题(QAbstractListModel类)
InfoModel类继承QAbstractListModel类,然后
QDeclarativeComponent component(m_qmlEngine, QUrl::fromLocalFile("..."));
QDeclarativeContext *context = new QDeclarativeContext(m_qmlEngine->rootContext());
QGraphicsObject *qml = qobject_cast<QGraphicsObject*>(component.create(context));
InfoModel *pageModel = new InfoModel;
context->setContextProperty("dataModel", pageModel);
struct Info
{
int id;
QString name;
int age;
};