gpt4 book ai didi

c++ - 在 Xcode 中开发 QT 应用程序?

转载 作者:可可西里 更新时间:2023-11-01 16:37:50 27 4
gpt4 key购买 nike

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

最佳答案

Google 显示了很多页面,但是这个 Qt4 with Xcode 页面乍一看似乎是一个相当权威的资源。但是,它最后一次更改是在 2006 年。

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

最近有一个 Qt Developer Network forum post这似乎有很好的信息。具体来说, this reply from August 19, 2011给出了完整的配方。


2016 年 5 月 25 日更新:

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

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

这是 emiguel 回答的拷贝。它现在已经 5 岁了,所以我不知道它现在有多新。

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

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

关于c++ - 在 Xcode 中开发 QT 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7812083/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com