QT declarative UI 初探(一)

手头的事情勉强告一段落,看到QT4.7的技术预览版中已经包含了 declarative UI,心中痒痒,要知道如果当初不是WPF太臃肿及不能跨平台,我们的项目已经在WPF+WCF的路上走的很远了(可以自豪的说,WPF+WCF的应用,无论国内还是国外,俺们项目组也算是走在前列的 *_*)。。。。

唔,远了,扯回来。先下了qt creator 2.0,装上,用2010.02的QT4.6版本跑了一下,偶尔会有异常,并且这个偶尔也太频繁了一点,有点失望。。。

搁置了两天,始终挡不住心中的好奇心,还是决定继续弄下去,于是下了4.7source包,开始编译,这里发个牢骚,不管是什么版本,也应该出个安装包吧。。。诺基亚的人被google赶的这点时间也没有了?

编译完成,说明一下,我用的编译器是2010.02 SDK中的 MINGW32-G++,Configure时没有特别指定任何参数,它就自己找到了(当然我的系统环境变量中是有设置这个路径的)。

好了,现在是学习时间,我打开$QTDIR/examples/declarative,哦,一堆的示例,好爽,看来示例足够学习了。。。且慢,为什么没有一个可执行文件,全是qml文件,我要如何运行?查看了一下文档,在Declarative UI (QML) 节的 GettingStarted 小节中有一个QML Examples and Walkthroughs 的链接,其指向的文档说要用qmlviewer来运行,原文如下:

You can find many simple examples in the examples/declarative sub-directory that show how to use various aspects of QML. In addition, thedemos/declarative sub-directory contains more sophisticated demos of large applications. These demos are intended to show integrated functionality rather than being instructive on specifice elements.

To run the examples and demos, use the included qmlviewer application. It has some useful options, revealed by:

 bin/qmlviewer -help

For example, from your build directory, run:

 bin/qmlviewer $QTDIR/demos/declarative/flickr/flickr-desktop.qml

or

 bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml

 

但是,我在bin目录下没有找到qmlviewer,只找到了一个qml.exe,双击运行,选择一个qml文件,唔,界面显示出来了。。。

但qmlviewer仍然让我产生了几个疑惑:

1.我找到的qml.exe是否就是qmlviewer?也就是说,文档中的qmlviewer写错了,其实应该是qml.exe?

2.qml.exe这个东东应该只是开发时的一个工具吧?我的declarative UI应用要如何发布?或者说我要如何建一个使用declarative UI的应用程序工程?

欲知后事如何,且看下回分解。。。

This entry was posted on Thursday, April 29th, 2010 at 5:01 PM and is filed under Qt技术. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “QT declarative UI 初探(一)”

  1. bug says:

    施主,你就快点写完吧。
    老衲等不及了

    • 英狐 says:

      呵呵,俺也想快,但如果一边记日志,一边学习,进度会慢一些,但这样思路和基础肯定会扎实一些^_^

  2. shun says:

    不知道博主是工作在什么平台下,win下的Qt库binary安装包不是一直都有么?
    我都是现在的qt4.7betaII :windows(minGW4.4.0)
    http://get.qt.nokia.com/qt/source/qt-win-opensource-4.7.0-beta2-mingw.exe
    另,想请教下QML用QDeclarativeView加载后可以和C++代码交换数据么?

    • 英狐 says:

      QML用QDeclarativeView加载后是可以和C++代码交换数据的。但我没有去测试过,看QT的介绍是有这一说的。具体如何操作可以查下文档。但我不建议现在就去深入QML,毕竟还在RC版。

      事实上我也在急切的期待正式版的发布,呵呵。

Leave a Reply