#include"ctestobject.h"#include<QDebug>CTestObject::CTestObject(QObject *parent):QObject(parent){}CTestObject::~CTestObject(){}//1.信号槽函数通讯voidCTestObject::testSlot(Type_RET ret){qDebug()<<"CTestObject:"<<"Hi I am CTestObject"<<ret;
emit sendMsg("Hi I am C++ CTestObject I recieved Calling");}//2.普通函数也可以被qml调用voidCTestObject::invokableFunc(const QVariant& var){qDebug()<<"CTestObject:"<<"Hi I am invokableFunc";qDebug()<<"From QML:"+var.toString();}//3.属性
QString CTestObject::name(){qDebug()<<"getName";return m_name;}voidCTestObject::setName(const QString &name){qDebug()<<"setName";
m_name = name;
emit nameChanged(m_name);}