//拖拽一个QQuickWidget
c++端和qml通信的桥梁
找到qml的main.qml的路径
ui->quickWidget->setSource(QUrl::fromLocalFile("../../../code/main.qml"));
// QML 与 Qt Widgets 通信
//窗口就成了一个类实例对象
pRoot = (QObject*)ui->quickWidget->rootObject();
此时目录结构,上面是c++,下面是qml
如何使用信号槽
c++端发给qml端
//c++端写一个信号触发qml端的信号
if (pRoot != NULL)
{
connect(ui->btn_circle, SIGNAL(clicked()), pRoot, SIGNAL(cSignal()));
}
//qml端这么写
signal cSignal
onCSignal()
{
}
qml端发给c++端
```connect(pRoot,SIGNAL(qml_ClickedCircle(QVariant,QVariant,double,double,double)),this,SLOT(slot_qml_CircleClicked(QVariant,QVariant,double,double,double)));