QGraphicsScene
我尝试使用以下代码将 qml 文件加载到 a中:
QGraphicsScene* scene = new QGraphicsScene;
QQmlEngine *engine = new QQmlEngine;
QQmlComponent component(engine,"main.qml",QQmlComponent::PreferSynchronous);
qDebug()<<component.errors();
QGraphicsObject *object =
qobject_cast<QGraphicsObject *>(component.create());
scene->addItem(object);
errors() 不返回任何内容,应用程序输出显示:
QGraphicsScene::addItem: cannot add null item