Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1042221
  • 博文数量: 264
  • 博客积分: 6005
  • 博客等级: 大校
  • 技术积分: 2798
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-08 20:15
文章分类

全部博文(264)

文章存档

2011年(42)

2010年(213)

2009年(4)

2008年(2)

2007年(3)

分类: C/C++

2010-10-07 08:05:28


// ! class define will be used instantiated in main function

class MyInterface : ...
{
...
    QPROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged)
...
};

// ! main function


#include <QApplication>
#include <QDeclarativeView>
#include <QDeclarativeContext>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QDeclarativeView view;
    QDeclarativeContext *context = view.rootContext();

    // Property:backgroundColor
    context->setContextProperty("backgroundColor", QColor(Qt::yellow));

   
//object: QObject *
    context->setContextObject(myInterface);

    view.setSource(QUrl::fromLocalFile("main.qml"));
    view.show();

    return app.exec();
}

// ! main.qml

...


阅读(2880) | 评论(0) | 转发(0) |
0

上一篇:Ragel State Machine Compiler

下一篇:随笔qt

给主人留下些什么吧!~~