qml信号绑定c++的槽函数
c++代码:
1,在c++定义个槽函数
public slots:
void doDecode(void);
qml代码:
1,在qml中定义一个信号:
signal startDecode()
2绑定c++的槽,xxx是注册到qml的c++对象
Component.onCompleted: {
startDecode.connect(xxx.doDecode)
}
c++信号绑定到qml的槽函数
c++代码:
1,在c++中定义一个信号
signals:
void resultNotify(void);
2,在合适机会发送信号,
emit resultNotify();
qml代码:
1,连接c++对象的信号,xxx是注册到qml中的c++对象
记得在c++的信号前面加on,并且c++的首字母大写
Connections{
target: xxx
onResultNotify:{
console.log('======************')
}
}