Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When compiling get error: 'QtGui/QAction' file not found #include <QtGui/QAction>

Tags:

c++

macos

qt

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>

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

UPDATE: I also tried this .pro file and it didn't work

QT       += core gui opengl
QT += widgets
TARGET = BasicOpenGL
TEMPLATE = app

I should say this is my first time attempting development on mac.

Compile Output from 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'

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.

like image 679
Celeritas Avatar asked Feb 04 '14 11:02

Celeritas


3 Answers

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.

like image 59
hluk Avatar answered Oct 14 '22 08:10

hluk


Try doing a make clean followed by a make. I had this exact problem on a Windows 7 system, and this is what worked for me.

like image 24
JPaget Avatar answered Oct 14 '22 07:10

JPaget


Set the version to Qt5, change all #include<QtQui/*>s into #include<QtWidgets/*>. And add QT += widgets in your .pro file. Rebuild the project, when you get the error again, tap into the error message, and change the #include<QtQui/*>s into #include<QtWidgets/*> too.

like image 2
mtyong Avatar answered Oct 14 '22 06:10

mtyong