如何使用Xcode编译qt .uic文件?
如何将 C++ 文件与 Qt 中的 .uic 文件链接起来?
How do I link up the C++ files with the .uic files in Qt?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何将 C++ 文件与 Qt 中的 .uic 文件链接起来?
How do I link up the C++ files with the .uic files in Qt?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
我建议使用 qmake。该工具大大简化了Qt编译过程。
所有 .ui 文件都必须转换为 C++ 代码并进行编译。
所有从 QObject 继承的类都必须由元对象编译器处理。
I suggest use qmake. This tool greatly simplifies the Qt compilation process.
All .ui files have to be converted into C++ code, and compiled.
All classes that inherit from QObject have to be processed by the meta object compiler.
*.ui
是设计器生成的用户界面文件。它们由uic
处理。尝试uic -h
获取帮助信息。qmake
默认会生成xcode工程文件,也可以生成Makefiles。*.ui
are user interface files generated by designer. They are processed byuic
. Tryuic -h
for help information.qmake
will generate xcode project files by default or can generate Makefiles.您可以在 Xcode 中添加规则。请参阅此链接,了解为 moc 添加信息的规则
http://gauthieralexandreblog.wordpress.com/2012/12/14/qt-and-xcode-4-5-how-to-moc-q_object-classes-automatically/< /a>
您可能想要为 moc 和 uic 添加规则。
我使用的是 Xcode 5.0.2,在“构建规则”选项卡下,我为“系统 C 规则”选择了“复制到目标”。这给了我一个小窗口,我可以像这样设置它:
Process: "Source Files With Names Matching" *.ui
使用:“自定义脚本”
脚本:
/Users/develop-brooke/Qt/5.2.1/clang_64/bin/uic -o ${INPUT_FILE_DIR}/GenerateFiles/ui_${INPUT_FILE_BASE}.h ${INPUT_FILE_PATH}
输出文件:
${INPUT_FILE_DIR}/GenerateFiles/ui_${INPUT_FILE_BASE}.h
显然指向你的Qt目录。如果需要,您可以省略GenerateFiles 目录。
将所有 ui 文件添加到构建阶段:编译源。构建一次后,返回并确保这些文件的路径位于您的项目中。我将它们添加到我的项目中。
最好的,
布鲁克
You can add a rule in Xcode. See this link for the rule adding info for the moc
http://gauthieralexandreblog.wordpress.com/2012/12/14/qt-and-xcode-4-5-how-to-moc-q_object-classes-automatically/
You will probably want to add rules for both the moc and uic.
I am using Xcode 5.0.2 and under the Build Rules tab I selected "Copy To Target" for "System C Rule". That gives me a little window where I set it up like so:
Process: "Source Files With Names Matching" *.ui
Using: "Custom Script"
Script:
/Users/develop-brooke/Qt/5.2.1/clang_64/bin/uic -o ${INPUT_FILE_DIR}/GeneratedFiles/ui_${INPUT_FILE_BASE}.h ${INPUT_FILE_PATH}
Output File:
${INPUT_FILE_DIR}/GeneratedFiles/ui_${INPUT_FILE_BASE}.h
Obviously point to your directory of Qt. You could omit the GeneratedFiles directory if you want.
Add all of your ui files to the Build Phase: Compile Sources. Once you build it once, go back and make sure the path to these files is in your project. I added them to my project.
Best,
Brooke