XCode中编译Qt的.ui文件和带Q_OBJECT的.h文件

1、编译带Q_OBJECT的类无法自动使用moc进行编译 

解决方法(参照:xcode - 如何在Xcode中使用Q_OBJECT宏编译头文件? | 文件):

(1)选择“Build Rules”-->选择好Process和Using的类型,然后在下面的输入框输入“/Users/你的用户名/Qt/5.14.2/clang_64/bin/moc ${INPUT_FILE_PATH} -o ${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}_moc.cpp”-->在“Output Files”中输入“$(DERIVED_FILE_DIR)/${INPUT_FILE_BASE}_moc.cpp”

XCode中编译Qt的.ui文件和带Q_OBJECT的.h文件_第1张图片

(2)选择“Build Phases”-->将带有Q_OBJECT的头文件加入“Compile Sources列表中”

XCode中编译Qt的.ui文件和带Q_OBJECT的.h文件_第2张图片

2、XCode无法自动编译Qt的.ui文件,类似上一条

解决方法:

(1)选择“Build Rules”-->选择好Process和Using的类型,然后在下面的输入框输入“/Users/你的用户名/Qt/5.14.2/clang_64/bin/uic ${INPUT_FILE_PATH} -o ${DERIVED_FILE_DIR}/ui_${INPUT_FILE_BASE}.h”-->在“Output Files”中输入“$(DERIVED_FILE_DIR)/ui_${INPUT_FILE_BASE}.h”

(2)选择“Build Phases”-->将.ui文件加入“Compile Sources列表中”

3、添加后可能编译报错“Multiple commands produce '****/ui_LearnOpenCV.h':”,原因是工程中已经有了处理.ui文件的规则,只要将其删除即可,如下图所示

XCode中编译Qt的.ui文件和带Q_OBJECT的.h文件_第3张图片​​​​​​​

参照:IOS下XCODE10错误:Multiple commands produce解决方法

4、运行报错:vtkOpenGLRenderWindow.c:506    ERR| vtkGenericOpenGLRenderWindow (0x11a20ca80): Unable to find a valid OpenGL 3.2 or later implementation. Please update your video card driver to the latest version. If you are using Mesa please make sure you have version 11.2 or later and make sure your driver in Mesa supports OpenGL 3.2 such as llvmpipe or openswr. If you are on windows and using Microsoft remote desktop note that it only supports OpenGL 3.2 with nvidia quadro cards. You can use other remoting software such as nomachine to avoid this issue.

解决方法(参照:VTK8.2 QT5.13 OpenGL3.2报错Unable to find a valid OpenGL 3.2 or later implementation_养老津贴的博客-CSDN博客):在main函数中开头添加:QSurfaceFormat::setDefaultFormat(QVTKOpenGLStereoWidget::defaultFormat());

​​​​​​​

你可能感兴趣的:(qt,xcode)