首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

Qt Creator 怎么编译窗体的 moc cpp h文件

2013-12-19 
Qt Creator 如何编译窗体的 moc cpp h文件我原先是用VS2012+Qt5的插件开发Qt程序,由于用的是vs2012的试用

Qt Creator 如何编译窗体的 moc cpp h文件
我原先是用VS2012+Qt5的插件开发Qt程序,由于用的是vs2012的试用版,现在vs2012过期了,我于是把项目挪到Qt Creator下继续开发,但是我发现原来在VS2012下,一个窗体UI会被编译成*.cpp, *h, moc_*.cpp等文件,而且有专门的右键菜单可以单独编译选定的UI,但是在Qt creator环境下,我没有找到有对于的右键菜单,有人说可以用uic命令行,但是我不知道如何用uic同时生产*.cpp, *h, moc_*.cpp

C:\Users\ehaiqhe>uic -h
Qt User Interface Compiler version 5.1.1
Usage: uic [options] <uifile>

  -h, -help                 display this help and exit
  -v, -version              display version
  -d, -dependencies         display the dependencies
  -o <file>                 place the output into <file>
  -tr <func>                use func() for i18n
  -p, -no-protection        disable header protection
  -n, -no-implicit-includes disable generation of #include-directives
                            for forms generated by uic3
  -g <name>                 change generator
[解决办法]

引用:
我发现原来在VS2012下,一个窗体UI会被编译成*.cpp, *h, moc_*.cpp等文件,而且有专门的右键菜单可以单独编译选定的UI


没用过商业版的VS+Qt,不清楚是否真的如你所说。

正常情况下,

.ui 只能通过uic生成 ui_xxxx.h 文件

然后手写 xxxx.h 和 xxxx.cpp 文件

构建过程中,包含Q_OBJECT宏的的.h/.cpp文件会通过moc生成 moc_xxxx.cpp/xxxx.moc 文件。

当然,在QtCreator下,如果你新建工程的话,wizard也会引导你完成这些东西。直观上就是自动生成这一堆东西。
[解决办法]
如果你注意力是实现功能的话,建议用qtcreator,移植代码应该很快。
[解决办法]
moc_xxx.cpp / xxx.moc 都是moc生成的,和ui没关系

热点排行