My first console C++ program on Qt Creator
-
Did you re-run qmake after modifying the .pro file ?
-
What do you get if you call make after that ?
-
Yes, that's it.
-
@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.
-
@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:
Why does the IDE think I'm C coding while I explicitly told it by choosing "plain C++" that I would be coding on C++?
I don't know. It works fine for me on Windows.
It might be related to your Kit settings (this is just a guess).
-
@tomy said in My first console C++ program on Qt Creator:
By the way, I'm on Linux. Have you tried a plain C++ project on Linux to see if there are those red underlines or not?
Unfortunately, I don't have a Linux machine with a recent version of Qt and Qt Creator.
One thing you could try is to create a Qt Console Application, then remove Qt from the .pro file.
-
@Cobra91151
Is it on Linux, please?
The options are different between Windows and Linux. -
I don't think that
Qt Creator
is different onLinux
andWindows
. Check: Tools -> Options -> Kits -> Compilers. Then select your compiler and click Browse. Your compiler should be "..\g++.exe" or something similar to it. Check if it's available for you.