编译时出现错误:找不到'QtGui/QAction'文件#include< QtGui/QAction> [英] When compiling get error: 'QtGui/QAction' file not found #include <QtGui/QAction>
问题描述
我刚刚安装了Mac OS X 10.8.3和Qt Creator 3,XCode和XCode命令行工具.我正在尝试编译可在另一台计算机上使用的项目,但是每次我去全部构建"时,都会得到error: 'QtGui/QAction' file not found
在#include <QtGui/QAction>
I just installed Mac OS X 10.8.3 and Qt Creator 3, XCode, and XCode command line tools. I'm trying to compile a project that works on another computer but each time I go to "build all" I get error: 'QtGui/QAction' file not found
in #include <QtGui/QAction>
我尝试在.pro文件中添加第二行和第三行,但没有帮助
I tried adding the second and third line in the .pro file but it didn't help
QT += core gui opengl
CONFIG += qt
QT += gui
TARGET = BasicOpenGL
TEMPLATE = app
更新:我也尝试了此.pro文件,但该文件不起作用
UPDATE: I also tried this .pro file and it didn't work
QT += core gui opengl
QT += widgets
TARGET = BasicOpenGL
TEMPLATE = app
我应该说这是我第一次尝试在Mac上进行开发.
I should say this is my first time attempting development on mac.
编译来自Qt的输出
Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/john/Qt/5.2.0/clang_64/lib -o mainwindow.o ../Framework/mainwindow.cpp
In file included from ../Framework/mainwindow.cpp:2:
../Framework/ui_mainwindow.h:14:10: fatal error: 'QtGui/QAction' file not found
#include <QtGui/QAction>
^
1 error generated.
make: *** [mainwindow.o] Error 1
15:51:32: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project BasicOpenGL (kit: Desktop Qt 5.2.0 clang 64bit)
When executing step 'Make'
更新:我可以使用它,但是在拧紧所有螺丝钉的情况下,我不确定该怎么做.我以全新的Mac映像开始,安装了系统更新,安装了xcode,安装了xcode命令行工具,安装了QT Creator 3.0,安装了QT库4.8.1,并在QT Creator中设置了编译器.
UPDATE: I got it to work but with all the screwing around I'm not exactly sure what did it. I started with a fresh mac image, installed system updates, installed xcode, installed xcode command line tools, installed QT Creator 3.0, installed QT libraries 4.8.1, setup the compilers in QT Creator.
推荐答案
在Qt5中,QAction
标头在QtWidgets
include子目录中,而不是在QtGui
中(对于Qt4而言是正确的).尽管实际上不需要指定include子目录,因为qmake
将为您处理.您只需将QT += widgets
添加到您的.pro
文件中.
In Qt5, QAction
header is in QtWidgets
include sub-directory, not in QtGui
(that's true for Qt4). Though you don't actually need to specify include sub-directories since qmake
will handle that for you. You just need to add QT += widgets
to your .pro
file.
这篇关于编译时出现错误:找不到'QtGui/QAction'文件#include< QtGui/QAction>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!