Qt Creator自动生成的垃圾(文件)的目的是什么,我如何驯服它们? [英] What is the purpose of the garbage (files) that Qt Creator auto-generates and how can I tame them?

查看:153
本文介绍了Qt Creator自动生成的垃圾(文件)的目的是什么,我如何驯服它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Qt还是很陌生,我正在使用新的诺基亚Qt SDK beta,我正在努力在空闲时间为诺基亚N900开发一个小型应用程序. 幸运的是,我能够正确设置所有内容,也可以在设备上运行我的应用程序.

I'm fairly new to Qt, and I'm using the new Nokia Qt SDK beta and I'm working to develop a small application for my Nokia N900 in my free time.
Fortunately, I was able to set up everything correctly, and also to run my app on the device.

我在学校学习过C ++,所以我认为这不会那么困难.
我将Qt Creator用作我的IDE,因为它不适用于Visual Studio.

I've learned C++ in school, so I thought it won't be so difficult.
I use Qt Creator as my IDE, because it doesn't work with Visual Studio.

我也希望将我的应用程序移植到Symbian,因此我已经运行了几次模拟器,并且还为Windows进行了编译,以调试最有害的错误. (调试器在设备上无法正常工作.)

I also wish to port my app to Symbian, so I have run the emulator a few times, and I also compile for Windows to debug the most evil bugs. (The debugger doesn't work correctly on the device.)

我来自.NET背景,所以有些事情我不理解.

I come from a .NET background, so there are some things that I don't understand.

当我按下构建按钮时,Qt Creator会在我的项目目录中生成一堆文件:

When I hit the build button, Qt Creator generates a bunch of files to my project directory:

  • moc_*.cpp文件-我不知道它们的用途.有人可以告诉我吗?
  • *.o文件-我假设这些是目标代码
  • *.rss文件-我不知道它们的用途,但是它们绝对与RSS没有任何关系
  • MakefileMakefile.Debug-我不知道
  • AppName(无扩展名)-Maemo的可执行文件,和AppName.sis-Symbian的可执行文件,我猜是吗?
  • AppName.loc-我不知道
  • AppName_installer.pkgAppName_template.pkg-我不知道
  • qrc_Resources.cpp-我想这是我的Qt资源
  • moc_*.cpp files - I don't know their purpose. Could someone tell me?
  • *.o files - I assume these are the object code
  • *.rss files - I don't know their purpose, but they definitely don't have anything to do with RSS
  • Makefile and Makefile.Debug - I have no idea
  • AppName (without extension) - the executable for Maemo, and AppName.sis - the executable for Symbian, I guess?
  • AppName.loc - I have no idea
  • AppName_installer.pkg and AppName_template.pkg - I have no idea
  • qrc_Resources.cpp - I guess this is for my Qt resources

(其中AppName是有问题的应用程序的名称)

(where AppName is the name of the application in question)

我注意到可以安全地删除这些文件,Qt Creator只需重新生成它们即可.
问题在于它们污染了我的源目录.尤其是因为我使用版本控制,并且如果可以重新生成它们,则将它们上传到SVN毫无意义.

I noticed that these files can be safely deleted, Qt Creator simply regenerates them.
The problem is that they pollute my source directory. Especially because I use version control, and if they can be regenerated, there is no point in uploading them to SVN.

那么,有人可以告诉我这些文件的确切用途是什么,我如何要求Qt Creator将它们放置在另一个目录中?

So, could someone please tell me what the exact purpose of these files is, and how can I ask Qt Creator to place them into another directory?

似乎我从这个问题的答案中学到的东西比我想的要多. :)
非常感谢所有帮助我的人.我给大家一个赞誉,因为我可以从每个答案中学到一些新东西.

It seems that I learned more from the answers of this question than I thought I would. :)
Big thanks to everyone who helped me out. I gave everyone an upvote, because I could learn something new from every answer.

实际上,Rob推荐的方法似乎是最方便的解决方案,但是我标记了Kotti的回答,因为他为我提供了有关Qt的构建机制如何工作的最佳解释.

Actually, what Rob recommended seems to be the most convenient solution, but I marked Kotti's answer accepted, because he provided me with the best explanation about how Qt's build mechanism works.

解决方案:

Maemo和Symbian工具链似乎都不支持影子构建,因此我在项目文件中使用了它们来解决这种情况:

It seems that neither the Maemo nor the Symbian toolchain supports shadow builds as of yet, so I use these in my project file to solve the situation:

DESTDIR = ./NoSVN
OBJECTS_DIR = ./NoSVN
MOC_DIR = ./NoSVN
RCC_DIR = ./NoSVN
UI_HEADERS_DIR = ./NoSVN

推荐答案

不是您问题的完整答案,而只是其中的一部分:)而且,它是可以谷歌搜索的.

Not a fully answer to your question, but just part of it :) Also, it's googlable.

猜想如果您使用C ++开发,则应该知道Makefile代表什么.另外,我认为.loc文件通常是具有本地化字符串/内容的文件.

Guess that if you develop in C++, you should know what does Makefile stand for. Also I think the .loc file is generally a file with localized strings / content.


(来源: thelins.se ) sub>


(source: thelins.se)

将C ++生成系统与Qt生成系统进行比较,您可以看到C ++生成系统(灰色框)保持不变.我们仍在这里构建C ++代码.但是,我们添加了更多的源和标头.这里涉及三个代码生成器:

Comparing the C++ build system to the Qt build system, you can see that the C++ build system, (the gray boxes), are left unmodified. We are still building C++ code here. However, we add more sources and headers. There are three code generators involved here:

元对象编译器(图中的moc) –元对象编译器采用所有以Q_OBJECT宏开头的类,并生成moc _ *.cpp C ++源文件.该文件包含有关要移动的类的信息,例如类名称,继承树等,还包括信号的实现.这意味着当您发出信号时,实际上是调用了由moc生成的函数.

The meta-object compiler (moc in the illustration) – the meta-object compiler takes all classes starting with the Q_OBJECT macro and generates a moc_*.cpp C++ source file. This file contains information about the class being moc’ed such as class name, inheritance tree, etc, but also implementation of the signals. This means that when you emit a signal, you actually call a function generated by the moc.

用户界面编译器(图中的uic) –用户界面编译器从Designer中获取设计并创建头文件.然后,这些头文件照常包含在源文件中,从而可以调用setupUi来实例化用户界面设计.

The user interface compiler (uic in the illustration) – The user interface compiler takes designs from Designer and creates header files. These header files are then included into source files as usual, making it possible to call setupUi to instanciate a user interface design.

Qt资源编译器(图中的rcc) –我们尚未讨论过资源编译器.它可以将图像,文本文件等嵌入到您的可执行文件中,但仍可以将它们作为文件进行访问.我们待会再看,我只想将它包括在它所属的图片中.

The Qt resource compiler (rcc in the illustration) – The resource compiler is something we have not talked about yet. It makes it possible to embedd images, text files, etc into your executable, but still to access them as files. We will look at this later, I just want to include it in this picture where it belongs.

我希望该插图阐明Qt真正为C ++添加新的漂亮关键字所做的工作.如果您好奇,请随时阅读一些生成的文件.只是不要更改它们-每次您构建应用程序时都会重新生成它们.

I hope this illustration clarifies what Qt really does to add new nice keywords to C++. If you are curious – feel free to read some of the generated files. Just don’t alter them – they are regenerated each time you build your application.

如果使用的是QtCreator,则moc文件将在项目目录的debug和release子目录中生成. uic文件存储在项目目录的根目录中. rcc文件通常很无聊,但是我敢肯定,您可以在项目目录层次结构中的某个位置找到它们.

If you are using QtCreator, the moc files are generated in the debug and release sub-directories of your project directory. The uic files are stored in the root of the project directory. The rcc files are generally boring, but I’m sure that you can find them in your project directory hierarcy somewhere.

您不必将这些文件包含到SVN中.这与提交.ncb.pdb和其他临时文件几乎一样.每次在Qt应用程序中进行更改时,这些临时文件都会作为更改的更新而重新生成,因此没有必要将它们提交到SVN.

You don't have to include these files into your SVN. This is pretty the same crap as commiting .ncb, .pdb and other temporary files. Every time you change something in your Qt application, these temporary files get regenerated as an update to your changes, so there is no sense to commit them to SVN.

这篇关于Qt Creator自动生成的垃圾(文件)的目的是什么,我如何驯服它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆