I have just installed QTCreator in Linux Ubuntu 20.04 LTS, I clicked on File->New Project->Application->QTConsole Application. A first.pro file and main.cpp file was made.
The first.pro contains:
QT -= gui declarative
QT += widgets
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES +=
main.cpp
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
The main.cpp contains:
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
The error comes in QCoreApplication line.
eyllanesc
233k19 gold badges163 silver badges235 bronze badges
asked Oct 3, 2020 at 7:16
2
The reason is that new versions of Qtcreator on Ubuntu 20.04 install clang-10
, but it still needing clang-8
.
Install clang-8 package:
apt install clang-8
answered Apr 2, 2021 at 18:35
Jorge LuisJorge Luis
89412 silver badges25 bronze badges
If the error is an open red circle, the code will still build.
If you want to get rid of the open red circles, go into Help->About Plugins and uncheck the Clang code model plugin. Then restart QT creator.
answered Apr 30, 2021 at 20:45
I’ve just installed Qt Creator and created console project. And when i want to run my project i have error: unknown type name ‘QCoreApplication’. But i didn’t write any code yet. Where is a problem, why qt doesn’t see it?
My code is:
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
My .pro file is:
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
asked Oct 23, 2020 at 9:28
1
@ADV Looks like your forgot include for QCoreApplication
, so it should be the first line of your main.cpp
file:
#include <QCoreApplication>
UPD:
Are you sure that you’ve choose valid Kit on Kit Selection phase:
To check Kits you have go to Tools->Options->Kits and check if your kits are valid and contains no exclamation marks.
To change kit used for current projects open «Projects» tab:
and select different kit.
answered Oct 23, 2020 at 9:33
trotro
6,8537 gold badges44 silver badges66 bronze badges
1
I’ve just installed Qt Creator and created console project. And when i want to run my project i have error: unknown type name ‘QCoreApplication’. But i didn’t write any code yet. Where is a problem, why qt doesn’t see it?
My code is:
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
My .pro file is:
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES +=
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
Hello to all,
I am cross compiling for an embedded development board and I have some strange issues with qt creator. qtbase was compiled successfully for the target board.
When I create a new project choosing the board that I want to build for, either a simple Console application or a QWidget application, from the first time that I configure the project, some issues appear in qt ‘Issues’ tab. Those issues concern the main types of like qt.
For console
main.cpp:7: error: unknown type name ‘QCoreApplication’
For QWidget
main.cpp:6: error: variable has incomplete type ‘QApplication’
qwindowdefs.h:81: forward declaration of ‘QApplication’
main.cpp:7: error: unknown type name ‘MainWindow’
The most strange thing is that the console program compiles and runs successfully remotely on the board, which gives me the indication that
Does anybody has any experience which any similar issue?
Thank you in advance
aplastiras
в mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
дает мне:
класс MainWindow: общедоступный
QMainWindow/home/joachim/Versuch/Test_2_HelloWorld/mainwindow.h:10: ошибка: ожидаемое имя класса
Q_OBJECT
/home/joachim/Versuch/Test_2_HelloWorld/mainwindow.h:12: ошибка: имя неизвестного типа ‘Q_OBJECT’
публичный:
/home/joachim/Versuch/Test_2_HelloWorld/mainwindow.h:14: ошибка: ожидаемое имя участника или ‘;’ после спецификаторов объявления
@шефф:
What’s wrong with it?
First I ignored this peculiar requirement of stackoverflow. Then I had to figure out what’S going on. Wasting 3min later it worked. Now in this post it doesn’t work again. I had to manually indent all lines.
That’s wrong with it.
Und nebenbei, dieser HTML Eingabeeditor ist der letzte Dreck. Der kann keinen richtigen Zeilenumbruch, Shift + return versteht der nicht. Ich hab schon wieder n Blutdruck… Wahrscheinlich geschrieben von den gleichen Typen die vi geschrieben haben, alles auf einer ach so geilen Codebase von Unix Sys V von 1969…