My first console C++ program on Qt Creator
-
Hello all,
I've started learning Linux and it's a good time to use the IDE (Qt Creator 4.8) for C++ console apps too.
So after creating a Plain C++ Application project I wrote a simple hello world program and ran it.
Here's the screenshot:What do I get these many errors please?
I though the IDE has the compiler for C++ console apps too.
How to solve these please?@tomy said in My first console C++ program on Qt Creator:
What do I get these many errors please?
For now, ignore those error messages and try to build and run your application anyway. Does it work? If not, do you see any new error messages?
-
Here it works
#include <QCoreApplication> #include <iostream> #include "QDebug" using namespace std; int main(int argc, char *argv[]) { cout << "Hello World!!!" << endl; qDebug() << "Hello World!!!"; // Qt way return 0; } Maybe you have got problems with the chosen platform.
-
@tomy said in My first console C++ program on Qt Creator:
What do I get these many errors please?
For now, ignore those error messages and try to build and run your application anyway. Does it work? If not, do you see any new error messages?
-
For now try this:
- Remove
CONFIG -= qt
- Add
QT =
- Remove
-
-
wrote on 21 Jan 2019, 21:38 last edited by
Here is .pro file:
TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle QT = SOURCES += \ main.cpp
Still the same errors!
-
Did you re-run qmake after modifying the .pro file ?
-
wrote on 21 Jan 2019, 21:43 last edited by tomy
-
What do you get if you call make after that ?
-
Yes, that's it.
-
wrote on 21 Jan 2019, 22:55 last edited byThis post is deleted!
-
wrote on 21 Jan 2019, 23:02 last edited by tomy
@SGaist
Thanks. I did it and it showed the output I wanted on the Terminal.
But still I see the errors and red lines on the code! :(Why while the program runs successfully does Qt Qreator show them? And how to get rid of them. They are ugly indeed.
-
Try changing the code model used by Qt Creator.
-
@tomy said in My first console C++ program on Qt Creator:
Of course. I get 6 issues. 5 of them are errors and one warning, as shown in the screenshot in the first post here.
The screenshot in your first post shows errors and warnings from the static code analyzer, not from your compiler. We can tell because the red circle and yellow triangles are "hollow". Errors and warnings from your compiler have "filled" circles and triangles.
Try to build and run your code to activate your compiler. Does it run successfully?
Anyway, you are seeing these errors because the static code analyzer thinks you are writing C code (not C++ code) for some reason. You can disable it by clicking Help > About Plugins... and unchecking C++ > Clang Code Model
@tomy said in My first console C++ program on Qt Creator:
If using qmake in Linux (Ubuntu) is this way, I did and below is the output. My project is on the Desktop named "hello_world".
I believe @SGaist meant running qmake from within Qt Creator, when your project is open. The menu item is Build > Run qmake.
Running qmake in the console does not change anything in Qt Creator.
-
What are the preferences choices for console C++ programming on the code model section, please?
How to find a way to be rid of these bothersome issues and go on programming?@tomy said in My first console C++ program on Qt Creator:
What are the preferences choices for console C++ programming on the code model section, please?
As I said in my previous post, you can disable the Clang Code Model clicking Help > About Plugins... and unchecking C++ > Clang Code Model
-
@tomy said in My first console C++ program on Qt Creator:
What are the preferences choices for console C++ programming on the code model section, please?
As I said in my previous post, you can disable the Clang Code Model clicking Help > About Plugins... and unchecking C++ > Clang Code Model
13/35