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
QtWS25 Last Chance

My first console C++ program on Qt Creator

Scheduled Pinned Locked Moved Solved General and Desktop
35 Posts 6 Posters 9.6k Views
  • 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.
  • S SGaist
    21 Jan 2019, 20:52

    For now try this:

    1. Remove CONFIG -= qt
    2. Add QT =
    T Offline
    T Offline
    tomy
    wrote on 21 Jan 2019, 21:22 last edited by
    #9

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

    A 1 Reply Last reply 21 Jan 2019, 21:27
    0
    • T tomy
      21 Jan 2019, 21:22

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

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 21 Jan 2019, 21:27 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
      • T Offline
        T Offline
        tomy
        wrote on 21 Jan 2019, 21:38 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 21 Jan 2019, 21:41 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

          T 1 Reply Last reply 21 Jan 2019, 21:43
          0
          • S SGaist
            21 Jan 2019, 21:41

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

            T Offline
            T Offline
            tomy
            wrote on 21 Jan 2019, 21:43 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
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 21 Jan 2019, 22:28 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

              T 1 Reply Last reply 21 Jan 2019, 22:36
              0
              • S SGaist
                21 Jan 2019, 22:28

                What do you get if you call make after that ?

                T Offline
                T Offline
                tomy
                wrote on 21 Jan 2019, 22:36 last edited by
                #15

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

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 21 Jan 2019, 22:41 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

                  T 2 Replies Last reply 21 Jan 2019, 22:55
                  1
                  • S SGaist
                    21 Jan 2019, 22:41

                    Yes, that's it.

                    T Offline
                    T Offline
                    tomy
                    wrote on 21 Jan 2019, 22:55 last edited by
                    #17
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • S SGaist
                      21 Jan 2019, 22:41

                      Yes, that's it.

                      T Offline
                      T Offline
                      tomy
                      wrote on 21 Jan 2019, 23:02 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
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 21 Jan 2019, 23:09 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

                        T 1 Reply Last reply 21 Jan 2019, 23:19
                        0
                        • J Offline
                          J Offline
                          JKSH
                          Moderators
                          wrote on 21 Jan 2019, 23:16 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
                          • S SGaist
                            21 Jan 2019, 23:09

                            Try changing the code model used by Qt Creator.

                            T Offline
                            T Offline
                            tomy
                            wrote on 21 Jan 2019, 23:19 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?

                            J 1 Reply Last reply 21 Jan 2019, 23:24
                            0
                            • T tomy
                              21 Jan 2019, 23:19

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

                              J Offline
                              J Offline
                              JKSH
                              Moderators
                              wrote on 21 Jan 2019, 23:24 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

                              T 1 Reply Last reply 21 Jan 2019, 23:27
                              1
                              • J JKSH
                                21 Jan 2019, 23:24

                                @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

                                T Offline
                                T Offline
                                tomy
                                wrote on 21 Jan 2019, 23:27 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++?

                                J 1 Reply Last reply 21 Jan 2019, 23:47
                                0
                                • T tomy
                                  21 Jan 2019, 23:27

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

                                  J Offline
                                  J Offline
                                  JKSH
                                  Moderators
                                  wrote on 21 Jan 2019, 23:47 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

                                  T 1 Reply Last reply 22 Jan 2019, 10:03
                                  0
                                  • J JKSH
                                    21 Jan 2019, 23:47

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

                                    T Offline
                                    T Offline
                                    tomy
                                    wrote on 22 Jan 2019, 10:03 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?

                                    C J 2 Replies Last reply 22 Jan 2019, 13:32
                                    0
                                    • T tomy
                                      22 Jan 2019, 10:03

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

                                      C Offline
                                      C Offline
                                      Cobra91151
                                      wrote on 22 Jan 2019, 13:32 last edited by
                                      #26

                                      @tomy

                                      Hi! I think the problem is with your compiler, try setting it as g++ not gcc.

                                      For example, using MinGW on Windows (compiler path is ....\g++.exe):

                                      0_1548163802423_2019-01-22_152922.png

                                      T 1 Reply Last reply 22 Jan 2019, 20:39
                                      1
                                      • T tomy
                                        22 Jan 2019, 10:03

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

                                        J Offline
                                        J Offline
                                        JKSH
                                        Moderators
                                        wrote on 22 Jan 2019, 15:12 last edited by
                                        #27

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

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

                                        1 Reply Last reply
                                        0
                                        • C Cobra91151
                                          22 Jan 2019, 13:32

                                          @tomy

                                          Hi! I think the problem is with your compiler, try setting it as g++ not gcc.

                                          For example, using MinGW on Windows (compiler path is ....\g++.exe):

                                          0_1548163802423_2019-01-22_152922.png

                                          T Offline
                                          T Offline
                                          tomy
                                          wrote on 22 Jan 2019, 20:39 last edited by
                                          #28

                                          @Cobra91151
                                          Is it on Linux, please?
                                          The options are different between Windows and Linux.

                                          C 1 Reply Last reply 22 Jan 2019, 20:46
                                          0

                                          18/35

                                          21 Jan 2019, 23:02

                                          • Login

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