博客首页 | 排行榜 |

wenes1的博客

个人档案
博文分类
QT ui文件介绍  2010-05-25 18:23

 

原文地址http://stone-pub.blog.sohu.com/74760031.html

QT ui文件介绍

 
1.生成方式:QT通过 QT designer 可以生成 ui文件 (.ui && .ui.h)
2.UI文件内容: 以XML方式记录了QT designer生成的界面的相关内容,大体可以分为如下内容
  • widget属性,其内容(图形元素, layout。。)的相关属性
  • 头文件  
  • 变量
  • 函数
3. 通过UIC (user interface compiler)可以把UI文件内容翻译成标准.h, .cpp文件
uic使用方法:
  • 生成声明(.h)文件:    uic [options]
    uic  [options] -subdecl   
    
  • 生成实现(.cpp)文件:uic [options] -impl
    uic  [options] -subimpl   
                                
    
选项:
  • -o file - write output to 'file' rather than to stdout.
  • -nofwd - omit forward declarations of custom classes in the generated header file. This is necessary if typedef classes are used.
  • -tr func - use func(sourceText, comment) rather than trUtf8(sourceText, comment) for internationalization.
4.使用: (IN Makefile)
%.h: %.ui
uic $< -o $@

%.cpp: %.ui
uic -impl $*.h $< -o $@

注:
.ui.h 文件包含ui文件功能实现部分(slot,function,include,variable)
更改.ui.h文件后(如:加入一个槽),可能.ui文件没有做自动改变,这样会导致编译失败,需手动更改.ui文件
QT 的Makefile会根据.ui文件生成相应源代码,而不是.ui.h文件

5.更改 .ui文件中的中文(.ui文件中中文为utf8, vi中显示不正常)
    iconv -f utf8 -t gbk input.ui > output.ui.gbk
    vi output.ui.gbk
    iconv -f gbk -t utf8 output.ui.gbk > input.ui

类别:默认 |
上一篇:Qt4中ui文件的使用方法 | 下一篇:Qt 中多线程的处理
以下网友评论只代表其个人观点,不代表本网站的观点或立场