行云

行至水穷处,坐看云起时。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

注册元类型
qRegisterMetaType<DVRDevUseRecords>("DVRDevUseRecords");
                                   类型                                名字
主要是在定义信号槽的时候,传递的参数类型不一定是QT所识别的,QT不识别的就要先注册以下,让QT能够认识,就是用qRegisterMetaType注册。
信号和槽
信号都是私有的,只能发送自己定义或继承的信号。
Slot无论是公有的还是私有的,另一个对象都可以根据信号触发。公有槽可以像public function members一样被使用。
只有对象内部才能产生信号吗?不是
可以这样 emit p->signal()
注意connect的时候,要用queue连接。
知道一个对象就能发送这个对象定义的信号

QT多线程
在一个耗时的计算中重复调用QEventLoop::processEvents()可以阻止GUI阻塞
http://qt-project.org/doc/qt-4.8/thread-basics.html

Qt安装与配置

开源版本下载地址:http://qt-project.org/downloads#qt-lib
Windows下编译安装:http://blog.csdn.net/mylxiaoyi/article/details/713058
用到mingw -- 只用自由软件来生成纯粹的Win32可执行文件的编译环境
1. 下载安装mingw: http://www.mingw.org/
2. 安装dev-cpp就可以用mingw:
http://download.csdn.net/tag/Devcpp-4.9.9.2/orderbydownloads
编译重要配置项:
-debug-and-release
-platform win32-msvc2005
Vs2005下安装配置编译QT
http://blog.csdn.net/feilinhe/article/details/4366004
http://blog.csdn.net/hellboysdnu/article/details/7525571

 编译步骤
1. 下载qt-everywhere-opensource-src-4.6.2.zip (这里假设解压放在C:\QTLib\4.6.2下)
2. 设置环境变量
    PATH中增加C:\QTLib\4.6.2\bin
    创建QMAKESPEC值为 win32-msvc2005
    创建QTDIR值为 C:\QTLib\4.6.2
3. 从VC 2005的安装路径找到vsvars32.bat(以你自己的安装目录为准)并运行,例如:在E:/Program Files/Microsoft Visual Studio 8/Common7/Tools
4. 到QT源码目录执行configure -platform win32-msvc2005 -fast -debug-and-release
    configure支持的选项输入configure /help查看
5. 执行nmake进行编译
6. VC编译环境设置
7. Visual stadio 中加入QT库
打开visual assist设置面板,选择project- >C/C++ Directories 将Platform选择为Custom,然后分别在stable include files 和src files中加入qt的include和src目录。重启vs后,assist即可以包含QT库。

相关资源
开源QT:http://qt-project.org/downloads#qt-lib
QT官网:http://qt.digia.com/
QT文档:qt-everywhere-opensource-src-4.6.2/doc(源码包中)
QT类查询:http://qt-project.org/doc/qt-4.8/qtgui.html
If you are new to Qt, you should probably start by going through the Tutorials, and then begin with the Application example.

第一个程序
新建一个空的工程

新建CPP文件

键入如下代码

打开visual Studio 2005 Command Prompt

如果直接用win+r – cmd则无法找到nmake(一些环境变量需要配置),用visual Studio 2005 Command Prompt就不需要再配置环境变量了。

把cpp保持在工程目录下,然后cd到工程目录,执行:
qmake –project
qmake
nmake
这样编译就完成了
参考:http://qt-project.org/doc/qt-4.8/gettingstartedqt.html

posted on 2013-03-12 14:44  windflying  阅读(643)  评论(0编辑  收藏  举报