Component.onCompleted:
{
//qml 信号连接 qml函数
sendMessageSigal.connect(getMessage);
}
Connections
{
//qml 连接 c++ 信号
target:interaction
onConnectcppsignal:
{
label2.text=strMsg;
}
}
//c++ 函数连接 qml信号
QObject* quitButton = root->findChild<QObject*>("quitButton");
if (quitButton)
{
QObject::connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()));
}
//连接c++ 信号与槽
//QObject::connect(this,SIGNAL(valueChanged(int)),this,SLOT(setValue(int))); //qt4 语法
QObject::connect(this,&CInteraction::valueChanged,this,&CInteraction::setValue); //qt5 新语法