用QDeclarativeView加载你的QML文件 语句如 view->setSource(QUrl::fromLocalFile("home/MainWindow.qml"));
如果要交互 做一个派生于QDeclarativeItem的对象 如 QMyDeClarativeItem : public QDeclarativeItem
要想使用你自定义的交互对象 :
要使用语句 qmlRegisterType<QTestBtn>("Buttons", 1, 0, "QMyDeClarativeItem"); //将C++定义元素注册为QML元素
在要使用的QML文件里导入 如 import Buttons 1.0