简体   繁体   English

在Xcode中开发QT应用程序?

[英]Developing QT applications in Xcode?

My IDE of choice for the Mac (at least for C++ and Objective-C development) is Xcode. 我选择Mac的IDE(至少用于C ++和Objective-C开发)是Xcode。 I have a 64-bit Intel Mac with OS X Lion installed, and Xcode version 4.2 downloaded from the Mac App Store. 我有一台安装了OS X Lion的64位Intel Mac,以及从Mac App Store下载的Xcode 4.2版。
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. 我的问题是Qt显然与Xcode 4不兼容(它在启动qmake生成的项目时崩溃),所以我基本上都在问我如何将Qt与Xcode集成。 I don't have to be able to run and debug the project from Xcode, just build it. 我不必从Xcode运行和调试项目,只需构建它。
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. 所以我认为在Xcode中使用qmake作为外部构建系统可能是一个解决方案,问题是我不知道如何将qmake设置为我的构建系统,这样我就可以在Xcode 4中开发我的Qt应用程序。
Please help me! 请帮我! :) :)

Google shows up many pages, but this Qt4 with Xcode page appeared at first glance to be a fairly definitive resource. 谷歌显示了许多页面,但这个 带有Xcode 页面的 Qt4 乍一看似乎是一个相当明确的资源。 However, it was last changed in 2006. 但是,它最后一次改变是在2006年。

Please check out: http://qt-project.org/doc/qt-5/macosx.html 请查看: 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. 有一个更新的Qt开发者网络论坛帖子似乎有很好的信息。 Specifically, this reply from August 19, 2011 gives a complete recipe. 具体来说, 2011年8月19日的回复给出了完整的配方。


Update 25/05/2016: 2016年5月25日更新:

The first two links are now dead, and not archived due to robots.txt . 由于robots.txt ,前两个链接现已死亡,未归档。

However, I've updated the link to the forum post. 但是,我已经更新了论坛帖子的链接。

And here's a copy of emiguel's answer. 这是emiguel答案的副本。 It is now 5 years old, so I don't know how current it still is. 现在已经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. 首先,我将在Qt中创建一个支持图形界面的子项目,我将此项目创建为C ++库,因此我可以将其包含在主项目中。

The main project is a C++ project in Xcode (which is a plugin template with a lot of configurations). 主要项目是Xcode中的C ++项目(这是一个包含大量配置的插件模板)。

Second, I ported the Qt project to Xcode using the spec macx-xcode parameter. 其次,我使用spec macx-xcode参数将Qt项目移植到Xcode。

Third, having both projects in Xcode, I can attatch the library (in Qt) to the main project. 第三,在Xcode中同时拥有这两个项目,我可以将库(在Qt中)附加到主项目中。 To do this, right click in the xcode project and click in the "existing file..." option, select the xcodeproj file from the Qt project. 要执行此操作,请右键单击xcode项目并单击“现有文件...”选项,从Qt项目中选择xcodeproj文件。 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". 最后将库添加到链接阶段,这是通过将lib文件(位于xcodeproj文件下)拖到“使用库链接二进制文件”中的“目标”部分来完成的。

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) 四,将Qt framewoks导入主项目,为此,右键单击主项目,单击添加现有框架,选择项目使用的Qt功能(例如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//**). 单击项目菜单 - >项目设置,使用Qt标头(ex QtSDK / include //)和库搜索路径(ex QtSDK / lib // **)设置标题搜索路径选项。

That's all, now I can instantiate my own Qt widgets from the C++ project. 这就是全部,现在我可以从C ++项目中实例化我自己的Qt小部件。

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. 注意:我必须做一个额外的步骤,因为我的目标是i386,下载的Qt版本是64位,所以我下载了源代码并为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... 最后,关于在Xcode中构建Qt的最新信息在Qt for OS X中可用 - 这在此处复制太长,并且将由Qt维护和更新...

I think this link might answer your question, or provide good information for those seeking an answer to this question: 我认为此链接可能会回答您的问题,或为寻求此问题答案的人提供良好的信息:

http://qt-project.org/doc/qtcreator-3.0/creator-developing-ios.html http://qt-project.org/doc/qtcreator-3.0/creator-developing-ios.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM