如何使用Xcode编译qt .uic文件?

发布于 2024-10-22 05:43:04 字数 37 浏览 6 评论 0原文

如何将 C++ 文件与 Qt 中的 .uic 文件链接起来?

How do I link up the C++ files with the .uic files in Qt?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吃→可爱长大的 2024-10-29 05:43:04

我建议使用 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.

故乡的云 2024-10-29 05:43:04

*.ui 是设计器生成的用户界面文件。它们由uic 处理。尝试uic -h 获取帮助信息。

qmake默认会生成xcode工程文件,也可以生成Makefiles。

*.ui are user interface files generated by designer. They are processed by uic. Try uic -h for help information.

qmake will generate xcode project files by default or can generate Makefiles.

[浮城] 2024-10-29 05:43:04

您可以在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文