如何设置Xcode而不是Qt Creator? [英] How to set up Xcode to work with instead of Qt Creator?

查看:175
本文介绍了如何设置Xcode而不是Qt Creator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有使用Qt Creator的UI设计功能。

I don't make use of Qt Creator's UI design functionality.

对于一个新项目,我想体验使用Xcode。这将是一个常规的Qt项目,使用C ++和Qt库开发,就像在Qt Creator中一样。

For a new project, I'd like to experience working with Xcode. This will be a regular Qt project, developed using C++ and Qt libraries just like in Qt Creator.

我没有使用OS X,尤其是Xcode的经验。

I have no experience using OS X and especially Xcode.


  • 设置和使用Xcode开发支持Qt Framework的Qt应用程序需要遵循哪些步骤? (即。代码完成或特殊错误等。)

我当然完成了我的搜索,但似乎没有任何关于方向的说明并且没有OS X或Xcode的任何经验使它变得复杂,因此我非常感谢您的耐心,逐步输入。在线提供的各种方法都不尽如人意。

I have of course done my search but nothing seems to be clear about directions and not having any experience with OS X or Xcode makes it complicated so therefore I'd really appreciate your patient, step-by-step input for this. Various how-tos available online are not of satisfactory.

平台:OS X,Qt 5.1

Platform: OS X, Qt 5.1

谢谢

推荐答案

你应该看一下 CMake的。它使用一种简单的语言在文本文件中定义项目,然后为您的环境生成本机项目文件(例如XCode)。

You should have a look at CMake. It uses a simple language to define projects in text files and then generates the native project files for your environment (eg XCode).

假设您的项目结构如下所示:
myproject /
MyProject.h
MyProject.cpp
main.cpp
MyGui.ui

Assuming your project structure looks like this: myproject/ MyProject.h MyProject.cpp main.cpp MyGui.ui

添加跟随 CMakeLists.txt 在同一目录中:

Add the following as CMakeLists.txt in the same directory:

cmake_mimimum_required( VERSION 2.8)

project( MyProject )

find_package( Qt4 COMPONENTS QtGui <insert components you need> REQUIRED)
include( ${QT_USE_FILE} )

# Qt's includes are already taken care of by the previous command
# add any additionaly include directories if required
# include "binary" dir to make sure the automatically generated files (eg for gui class) are found
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )

# assuming MyProject contains a Q_OBJECT that needs to be processed by moc
QT4_WRAP_CPP( MOCS MyProject.h )   

QT4_WRAP_UI( UI MyGui.ui )

add_executable( MyProject 
      MyProject.cpp
      MyProject.h
      ${MOCS}
      ${UI}
)

target_link_libraries( MyProject ${QT_LIBRARIES} )

创建二进制目录。该目录将包含您的XCode文件以及在项目期间生成的任何文件(编译对象等)。因此,CMake允许从源代码中轻松分离生成的文件,因此不会弄乱您的源代码控制。

Create the "binary" directory. This directory will contain your XCode files and any files that are generated during the project (compiled objects etc). Thus, CMake allows easy separation of generated files from your source code so it doesn't mess up your source control.

在二进制目录中,调用:

In the binary directory, call:

cmake -G XCode <path to your source directory (where CMakeLists.txt is)>

您还可以使用GUI工具 CMake-Gui 或者控制台gui ccmake

You could also use the GUI tool CMake-Gui or console gui ccmake.

在cmake完成生成项目文件后,在XCode中打开它们。

After cmake finished generating the project files, open them in XCode.

有关详细信息,请查看 CMake文档

For more details, check the CMake documentation

快乐编码!

(免责声明:代码未经测试。 )

(Disclaimer: Code is untested.)

这篇关于如何设置Xcode而不是Qt Creator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆