在 Xcode 中开发 QT 应用程序?

发布于 2024-12-10 14:52:29 字数 350 浏览 0 评论 0原文

我选择的 Mac IDE(至少对于 C++ 和 Objective-C 开发)是 Xcode。我有一台安装了 OS X Lion 的 64 位 Intel Mac,并从 Mac App Store 下载了 Xcode 版本 4.2。
我的问题是 Qt 显然与 Xcode 4 不兼容(启动 qmake 生成的项目时会崩溃),所以我基本上是在问如何将 Qt 与 Xcode 集成。我不必能够从 Xcode 运行和调试项目,只需构建它即可。
所以我认为这可能是在 Xcode 中使用 qmake 作为外部构建系统的解决方案,问题是我不知道如何将 qmake 设置为我的构建系统,以便我可以在 Xcode 4 中开发我的 Qt 应用程序。< br> 请帮我! :)

My IDE of choice for the Mac (at least for C++ and Objective-C development) is Xcode. I have a 64-bit Intel Mac with OS X Lion installed, and Xcode version 4.2 downloaded from the Mac App Store.
My problem is that Qt is apparently not compatible with Xcode 4 (it crashes when launching projects generated by qmake), so I'm basically asking how I can integrate Qt with Xcode. I don't have to be able to run and debug the project from Xcode, just build it.
So I thought it might be a solution to use qmake as an external build system within Xcode, the problem is that I have no idea how to set up qmake as my build system, so that I can develop my Qt applications in Xcode 4.
Please help me! :)

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

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

发布评论

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

评论(1

百善笑为先 2024-12-17 14:52:29

Google 显示了很多页面,但是这个 Qt4 with Xcode 页面第一眼就出现了成为相当明确的资源。不过,最后一次更改是在 2006 年。

请查看:http:// /qt-project.org/doc/qt-5/macosx.html

有一个更新的Qt 开发者网络论坛帖子 似乎有里面有很好的信息。具体来说,2011 年 8 月 19 日的回复 给出了完整的食谱。


2016 年 5 月 25 日更新:

前两个链接现已失效,并且由于 robots.txt 的原因未存档。

不过,我已经更新了论坛帖子的链接。

这是埃米格尔的答案的副本。现在已经5年了,所以我不知道它现在还如何。

嗨,

为了解决我的问题,我执行了以下操作。

首先,我将在 Qt 中有一个子项目来维护图形界面,我将这个项目创建为 C++ 库,因此我可以将其包含在主项目中。

主项目是Xcode中的一个C++项目(这是一个有很多配置的插件模板)。

其次,我使用spec macx-xcode 参数将 Qt 项目移植到 Xcode。

第三,在 Xcode 中拥有两个项目,我可以将库(在 Qt 中)附加到主项目。为此,右键单击 xcode 项目,然后单击“现有文件...”选项,从 Qt 项目中选择 xcodeproj 文件。最后将库添加到链接阶段,这是通过将 xcodeproj 文件下的 lib 文件拖动到“使用库链接二进制文件”中的“目标”部分来完成的。

第四,将Qt框架导入到主项目中,为此,在主项目中右键单击,单击添加现有框架,选择项目使用的Qt功能(例如QtSDK/lib/QtCore.framework )

最后,在主项目中添加标头和库路径。单击项目菜单 -> 项目设置,使用 Qt 标头(例如 QtSDK/include//)和库搜索路径(例如 QtSDK/lib//**)设置标头搜索路径选项。

就这样,现在我可以从 C++ 项目实例化我自己的 Qt 小部件了。

注意:我必须执行额外的步骤,因为我的目标是 i386 并且下载的 Qt 版本是 64 位,因此我下载了源代码并针对 i386 进行了编译。

现在我在绘制插件内部时遇到了另一个问题......但我认为这将是另一篇文章的内容。

非常感谢您的帮助

最后,有关在 Xcode 中构建 Qt 的最新信息可在 Qt for OS 中找到X - 太长了,无法复制到这里,将由 Qt 维护和更新......

Google shows up many pages, but this Qt4 with Xcode page appeared at first glance to be a fairly definitive resource. However, it was last changed in 2006.

Please check out: http://qt-project.org/doc/qt-5/macosx.html

There is a much more recent Qt Developer Network forum post that seems to have good info in it. Specifically, this reply from August 19, 2011 gives a complete recipe.


Update 25/05/2016:

The first two links are now dead, and not archived due to robots.txt.

However, I've updated the link to the forum post.

And here's a copy of emiguel's answer. It is now 5 years old, so I don't know how current it still is.

Hi,

To solve my problem I did the following.

First I`m going to have a subproject in Qt that mantains the graphical interface, I created this project as a C++ library, so I could include this in the main project.

The main project is a C++ project in Xcode (which is a plugin template with a lot of configurations).

Second, I ported the Qt project to Xcode using the spec macx-xcode parameter.

Third, having both projects in Xcode, I can attatch the library (in Qt) to the main project. To do this, right click in the xcode project and click in the "existing file..." option, select the xcodeproj file from the Qt project. Finally add the library to the linkage phase, this is done by dragging the lib file, wich is under the xcodeproj file, to the "Targets" section in the "Link binary with Libraries".

Fourth, import the Qt framewoks to the main project, to do that, right click in the main project, click in add a existing framework, select the Qt features used by the project (ex. QtSDK/lib/QtCore.framework)

And finally, add the header and library paths in the main project. Click in project menu->project settings, set the header search paths option with the Qt headers (ex QtSDK/include//) and the library search paths (ex QtSDK/lib//**).

That's all, now I can instantiate my own Qt widgets from the C++ project.

Note: I have to do an additional step because my target was i386 and the downloaded Qt version were 64 bit, so I downloaded the sources and compiled it for i386.

Now I have another problems about drawing inner the plugin... but I think that will be for another post.

Thanks a lot for your help

Finally, current information on building Qt in Xcode is available in Qt for OS X - which is too long to copy here, and will be maintained and updated by Qt...

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