三十九、QtDeclarative模块
这个模块的作用就是将QML元素与标准C++类相结合。而且它提供了一个很简单的方法使新建的QML文件作为一个项目加入到以前的图形视图的应用中。下面我们来看一个简单的例子。//main.qml
import QtQuick 1.0
Rectangle {
width: 200
height: 200
color:"green"
Rectangle {
id: rectangle1
x: 50
y: 50
width: 100
height: 100
color: "blue"
radius: 30
}
}
//man.cpp
#include <QtDeclarative/QDeclarativeView>
#include <QtDeclarative/QDeclarativeItem>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeComponent>
#include <QtGui>
int main(int argc, char** argv)
{
QApplication app(argc,argv);
QDeclarativeEngine engine;
QDeclarativeComponent component