Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. My first console C++ program on Qt Creator
Forum Updated to NodeBB v4.3 + New Features

My first console C++ program on Qt Creator

Scheduled Pinned Locked Moved Solved General and Desktop
35 Posts 6 Posters 11.9k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Hi,

    Can you show your .pro file ?

    tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by
    #6

    @SGaist

    Hi, here it is:

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG -= qt
    
    SOURCES += \
            main.cpp
    
    1 Reply Last reply
    0
    • JKSHJ JKSH

      @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?

      tomyT Offline
      tomyT Offline
      tomy
      wrote on last edited by
      #7

      @JKSH

      Of course. I get 6 issues. 5 of them are errors and one warning, as shown in the screenshot in the first post here.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #8

        For now try this:

        1. Remove CONFIG -= qt
        2. Add QT =

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        tomyT 1 Reply Last reply
        2
        • SGaistS SGaist

          For now try this:

          1. Remove CONFIG -= qt
          2. Add QT =
          tomyT Offline
          tomyT Offline
          tomy
          wrote on last edited by
          #9

          @SGaist
          I removed the first line.
          But the second line is half incomplete! Add what to what?

          aha_1980A 1 Reply Last reply
          0
          • tomyT tomy

            @SGaist
            I removed the first line.
            But the second line is half incomplete! Add what to what?

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #10

            @tomy Just add the line as @SGaist wrote. This will add no Qt modules, not even core.

            Qt has to stay free or it will die.

            1 Reply Last reply
            0
            • tomyT Offline
              tomyT Offline
              tomy
              wrote on last edited by
              #11

              Here is .pro file:

              TEMPLATE = app
              CONFIG += console c++11
              CONFIG -= app_bundle
              QT =
              SOURCES += \
                      main.cpp
              

              Still the same errors!

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #12

                Did you re-run qmake after modifying the .pro file ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                tomyT 1 Reply Last reply
                0
                • SGaistS SGaist

                  Did you re-run qmake after modifying the .pro file ?

                  tomyT Offline
                  tomyT Offline
                  tomy
                  wrote on last edited by tomy
                  #13

                  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".

                  0_1548109120848_1.png

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    What do you get if you call make after that ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    tomyT 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      What do you get if you call make after that ?

                      tomyT Offline
                      tomyT Offline
                      tomy
                      wrote on last edited by
                      #15

                      @SGaist
                      Do you mean I type "make" on the last line?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        Yes, that's it.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        tomyT 2 Replies Last reply
                        1
                        • SGaistS SGaist

                          Yes, that's it.

                          tomyT Offline
                          tomyT Offline
                          tomy
                          wrote on last edited by
                          #17
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Yes, that's it.

                            tomyT Offline
                            tomyT Offline
                            tomy
                            wrote on last edited by tomy
                            #18

                            @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.

                            0_1548111980062_1.png

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #19

                              Try changing the code model used by Qt Creator.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              tomyT 1 Reply Last reply
                              0
                              • JKSHJ Offline
                                JKSHJ Offline
                                JKSH
                                Moderators
                                wrote on last edited by
                                #20

                                @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".

                                0_1548109120848_1.png

                                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.

                                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                1 Reply Last reply
                                4
                                • SGaistS SGaist

                                  Try changing the code model used by Qt Creator.

                                  tomyT Offline
                                  tomyT Offline
                                  tomy
                                  wrote on last edited by
                                  #21

                                  @SGaist

                                  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?

                                  JKSHJ 1 Reply Last reply
                                  0
                                  • tomyT tomy

                                    @SGaist

                                    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?

                                    JKSHJ Offline
                                    JKSHJ Offline
                                    JKSH
                                    Moderators
                                    wrote on last edited by
                                    #22

                                    @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

                                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                    tomyT 1 Reply Last reply
                                    1
                                    • JKSHJ JKSH

                                      @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

                                      tomyT Offline
                                      tomyT Offline
                                      tomy
                                      wrote on last edited by
                                      #23

                                      @JKSH
                                      Thanks so much. It removed the majority of the red underlines.
                                      Only two lines remain!

                                      0_1548113155555_1.png

                                      One more thing: 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++?

                                      JKSHJ 1 Reply Last reply
                                      0
                                      • tomyT tomy

                                        @JKSH
                                        Thanks so much. It removed the majority of the red underlines.
                                        Only two lines remain!

                                        0_1548113155555_1.png

                                        One more thing: 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++?

                                        JKSHJ Offline
                                        JKSHJ Offline
                                        JKSH
                                        Moderators
                                        wrote on last edited by
                                        #24

                                        @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).

                                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                        tomyT 1 Reply Last reply
                                        0
                                        • JKSHJ JKSH

                                          @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).

                                          tomyT Offline
                                          tomyT Offline
                                          tomy
                                          wrote on last edited by
                                          #25

                                          @JKSH
                                          Kids are only the Desktop kit:

                                          0_1548151415171_1.png

                                          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?

                                          Cobra91151C JKSHJ 2 Replies Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved