Home > Software design >  Cannot build a Qt project
Cannot build a Qt project

Time:11-22

Recently I stumbled upon a quite itchy problem. I had to open a qt project, which I cloned from repository version. I opened it and tried to build. Hardly was there a non-red line. I got tons of compiler errors:

Unknown type name 'QString'
Unknown type name 'QSqlDatabase'
Unknown type name 'Q_OBJECT'
'QWidget' file not found

and others. I suppose the problem is somewhere in my Qt Creator or in .pro file, as the actual developers of the project had no problem running it.

I'm using Qt 6.4.1

Here's my .pro file:

QT        = core gui
QT        = sql

greaterThan(QT_MAJOR_VERSION, 4): QT  = widgets

CONFIG  = c  17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES  = QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES  = all necessary .cpp files\

HEADERS  = all necessary .h files\

FORMS  = all necessary .ui files\
    

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS  = target

CodePudding user response:

Actually, the thing that might resolve the situation is simple. Just ensure you placed your project in the correct local drive (if it isn't, my Qt Creator seems not see the Qt itself). Then the project should be rebuilded properly after what all must fully work.

If only you imagined how long I've been fighting this annoying problem... It surely isn't worth that.

CodePudding user response:

Check that your app build path contains only english charecters. Or try make a simple example to verify your kit

  • Related