QApplication: no such file or directory

I installed QT4 Creator in / usr / programs / qt, add in PATH / usr / programs / qt / bin, QTDIR = / usr / programs / qt, LD_LIBRARY_PATH = $ QTDIR / lib, as well as for MANPATH and export. The problem is that the demos work fine, but when I create a new project in a different directory, for example / home / Jane / it does not work, I got errors, for example

/ home / jane / test-embedded desktop /../ test / main.cpp: 1: Error: QApplication: There is no such file or directory / home / Jane / test -build-desktop /../ test / main.cpp : 2: Error: QLabel: No such file or directory

 #include <QApplication>
 #include <QLabel>
 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
     QLabel *label = new QLabel("Hello Qt!");
     label->show();
     return app.exec();
}

Can someone help me?

+3
source share
6 answers

Add to your .pro file:

QT += gui
+6
source

. ".pro"

QT -= gui

QT += gui

+6
QApplication: No such file or directory ...

QT + =

.pro. ... , 5.0 Qt ...

+3

, Qt 5.7

.pro :

QT += widgets

Qt " qmake"

qmake

, , .

+1

.pro :

QT       -= gui

. , gui .

,

QT       += gui

, gui .

0

Ubuntu 14.04, :

ABC$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o textpad.o textpad.cpp
textpad.cpp:1:24: fatal error: QApplication: No such file or directory
 #include <QApplication>
                        ^
compilation terminated.
make: *** [textpad.o] Error 1

Try it qmake-qt4, then make. Of course, you can get all QT4 libraries if they are not used:

sudo apt-get install libqt4-dev 
0
source

Source: https://habr.com/ru/post/1794255/


All Articles