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. Qt Programming Language
Forum Update on Monday, May 27th 2025

Qt Programming Language

Scheduled Pinned Locked Moved Unsolved General and Desktop
331 Posts 17 Posters 309.8k 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.
  • A Annabelle
    23 Jul 2019, 18:11

    @JKSH said in Qt Programming Language:

    @Annabelle said in Qt Programming Language:

    And now when I try to compile my "Hello World" project, I get this error.

    The error says that your compiler is too old and it doesn't support the C++ 2011 standard. But I'm confused: If you're doing a basic C++ Hello World program, why is Code::Blocks trying to include Qt?

    I suggest you leave Qt out for now. Just focus on learning plain C++. This way, it doesn't matter if you have an old compiler.

    Now when I compile a project, with regular C++ code, here's what I got in return.

    0_1563905512388_14fc52e1-5a2f-4ad6-9bde-9e719908888d-image.png

    J Offline
    J Offline
    JonB
    wrote on 23 Jul 2019, 18:33 last edited by JonB
    #302

    @Annabelle
    It looks like you have progressed! It seems to be successfully rubnning your gcc compiler.

    You should open up your Sources folder in the left-hand pane so that we can see what file(s) you have. And perhaps open your main/only .cpp source file into the right-hand pane so that we can see that too.

    The error message indicates that some .cpp source file has an "odd" character in it, on line #9. The sort of stray character that perhaps got in there from a mis-typing.

    1 Reply Last reply
    3
    • A Annabelle
      23 Jul 2019, 18:11

      @JKSH said in Qt Programming Language:

      @Annabelle said in Qt Programming Language:

      And now when I try to compile my "Hello World" project, I get this error.

      The error says that your compiler is too old and it doesn't support the C++ 2011 standard. But I'm confused: If you're doing a basic C++ Hello World program, why is Code::Blocks trying to include Qt?

      I suggest you leave Qt out for now. Just focus on learning plain C++. This way, it doesn't matter if you have an old compiler.

      Now when I compile a project, with regular C++ code, here's what I got in return.

      0_1563905512388_14fc52e1-5a2f-4ad6-9bde-9e719908888d-image.png

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 24 Jul 2019, 00:00 last edited by
      #303

      @Annabelle said in Qt Programming Language:

      Now when I compile a project, with regular C++ code, here's what I got in return.

      The error message is "stray '\240' in program". This means your .cpp file contains a character that the compiler does not accept.

      '\240' is a specially-formatted character that represents a space. It can appear when someone copies code from a website or a program like Microsoft Word, and then pastes it into their IDE.

      Your compiler says that the error is in line 9. I suggest you completely erase lines 8 to 10 to get rid of the '\240' character, and then re-type those lines by hand.

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

      A 1 Reply Last reply 24 Jul 2019, 01:30
      4
      • J JKSH
        24 Jul 2019, 00:00

        @Annabelle said in Qt Programming Language:

        Now when I compile a project, with regular C++ code, here's what I got in return.

        The error message is "stray '\240' in program". This means your .cpp file contains a character that the compiler does not accept.

        '\240' is a specially-formatted character that represents a space. It can appear when someone copies code from a website or a program like Microsoft Word, and then pastes it into their IDE.

        Your compiler says that the error is in line 9. I suggest you completely erase lines 8 to 10 to get rid of the '\240' character, and then re-type those lines by hand.

        A Offline
        A Offline
        Annabelle
        wrote on 24 Jul 2019, 01:30 last edited by
        #304

        @JKSH said in Qt Programming Language:

        @Annabelle said in Qt Programming Language:

        Now when I compile a project, with regular C++ code, here's what I got in return.

        The error message is "stray '\240' in program". This means your .cpp file contains a character that the compiler does not accept.

        '\240' is a specially-formatted character that represents a space. It can appear when someone copies code from a website or a program like Microsoft Word, and then pastes it into their IDE.

        Your compiler says that the error is in line 9. I suggest you completely erase lines 8 to 10 to get rid of the '\240' character, and then re-type those lines by hand.

        What's the \240 character? I'm confused on that one!

        J 1 Reply Last reply 24 Jul 2019, 02:17
        0
        • A Annabelle
          24 Jul 2019, 01:30

          @JKSH said in Qt Programming Language:

          @Annabelle said in Qt Programming Language:

          Now when I compile a project, with regular C++ code, here's what I got in return.

          The error message is "stray '\240' in program". This means your .cpp file contains a character that the compiler does not accept.

          '\240' is a specially-formatted character that represents a space. It can appear when someone copies code from a website or a program like Microsoft Word, and then pastes it into their IDE.

          Your compiler says that the error is in line 9. I suggest you completely erase lines 8 to 10 to get rid of the '\240' character, and then re-type those lines by hand.

          What's the \240 character? I'm confused on that one!

          J Offline
          J Offline
          JKSH
          Moderators
          wrote on 24 Jul 2019, 02:17 last edited by JKSH
          #305

          @Annabelle said in Qt Programming Language:

          What's the \240 character? I'm confused on that one!

          As I mentioned before, it is a specially-formatted character that represents a space.

          There are many ways to represent text: Sighted people draw lines to represent a character, Braille users arrange dot patterns to represent a character, while computers use a number to represent a character. For example, computers represent 'A' as the number 65, 'B' as the number 66, and so on.

          In computers, there are multiple ways to represent a space. \240 is one such representation. Unfortunately, this representation causes problems for your compiler when it is pasted into your IDE.

          Since it is a space character, I doubt that your screenreader will read it out. Sighted people can't see the bad character on the screen either.

          The easiest thing to do is to erase the offending line from your code and re-type the whole line by hand.

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

          A 1 Reply Last reply 24 Jul 2019, 11:11
          4
          • J JKSH
            24 Jul 2019, 02:17

            @Annabelle said in Qt Programming Language:

            What's the \240 character? I'm confused on that one!

            As I mentioned before, it is a specially-formatted character that represents a space.

            There are many ways to represent text: Sighted people draw lines to represent a character, Braille users arrange dot patterns to represent a character, while computers use a number to represent a character. For example, computers represent 'A' as the number 65, 'B' as the number 66, and so on.

            In computers, there are multiple ways to represent a space. \240 is one such representation. Unfortunately, this representation causes problems for your compiler when it is pasted into your IDE.

            Since it is a space character, I doubt that your screenreader will read it out. Sighted people can't see the bad character on the screen either.

            The easiest thing to do is to erase the offending line from your code and re-type the whole line by hand.

            A Offline
            A Offline
            Annabelle
            wrote on 24 Jul 2019, 11:11 last edited by
            #306

            @JKSH said in Qt Programming Language:

            @Annabelle said in Qt Programming Language:

            What's the \240 character? I'm confused on that one!

            As I mentioned before, it is a specially-formatted character that represents a space.

            There are many ways to represent text: Sighted people draw lines to represent a character, Braille users arrange dot patterns to represent a character, while computers use a number to represent a character. For example, computers represent 'A' as the number 65, 'B' as the number 66, and so on.

            In computers, there are multiple ways to represent a space. \240 is one such representation. Unfortunately, this representation causes problems for your compiler when it is pasted into your IDE.

            Since it is a space character, I doubt that your screenreader will read it out. Sighted people can't see the bad character on the screen either.

            The easiest thing to do is to erase the offending line from your code and re-type the whole line by hand.

            I typed the offending line by hand, and here's what I got.
            0_1563966708194_ba140787-381a-4ed3-9668-989f1535714a-image.png

            J 1 Reply Last reply 24 Jul 2019, 11:14
            2
            • A Annabelle
              24 Jul 2019, 11:11

              @JKSH said in Qt Programming Language:

              @Annabelle said in Qt Programming Language:

              What's the \240 character? I'm confused on that one!

              As I mentioned before, it is a specially-formatted character that represents a space.

              There are many ways to represent text: Sighted people draw lines to represent a character, Braille users arrange dot patterns to represent a character, while computers use a number to represent a character. For example, computers represent 'A' as the number 65, 'B' as the number 66, and so on.

              In computers, there are multiple ways to represent a space. \240 is one such representation. Unfortunately, this representation causes problems for your compiler when it is pasted into your IDE.

              Since it is a space character, I doubt that your screenreader will read it out. Sighted people can't see the bad character on the screen either.

              The easiest thing to do is to erase the offending line from your code and re-type the whole line by hand.

              I typed the offending line by hand, and here's what I got.
              0_1563966708194_ba140787-381a-4ed3-9668-989f1535714a-image.png

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 24 Jul 2019, 11:14 last edited by
              #307

              @Annabelle Looks good, it works

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply 24 Jul 2019, 12:22
              2
              • O Offline
                O Offline
                ODБOï
                wrote on 24 Jul 2019, 11:45 last edited by ODБOï
                #308

                @Annabelle said in Qt Programming Language:

                not sure Qt is a Programming Language, maybe this was already discussed, hard to know when topic has 300+ posts...
                It looks like the OP never created a new thread and asked all his questions in the same one.

                M 1 Reply Last reply 24 Jul 2019, 11:54
                0
                • O ODБOï
                  24 Jul 2019, 11:45

                  @Annabelle said in Qt Programming Language:

                  not sure Qt is a Programming Language, maybe this was already discussed, hard to know when topic has 300+ posts...
                  It looks like the OP never created a new thread and asked all his questions in the same one.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 24 Jul 2019, 11:54 last edited by
                  #309

                  @LeLev
                  Hi
                  She is using a screen reader so I think its easier for her to use the same thread.

                  O 1 Reply Last reply 24 Jul 2019, 11:56
                  2
                  • M mrjj
                    24 Jul 2019, 11:54

                    @LeLev
                    Hi
                    She is using a screen reader so I think its easier for her to use the same thread.

                    O Offline
                    O Offline
                    ODБOï
                    wrote on 24 Jul 2019, 11:56 last edited by
                    #310

                    @mrjj ah ok! my bad

                    1 Reply Last reply
                    1
                    • J jsulm
                      24 Jul 2019, 11:14

                      @Annabelle Looks good, it works

                      A Offline
                      A Offline
                      Annabelle
                      wrote on 24 Jul 2019, 12:22 last edited by
                      #311

                      @jsulm said in Qt Programming Language:

                      @Annabelle Looks good, it works

                      Cool-ee-o! So what do I do next?

                      A 1 Reply Last reply 24 Jul 2019, 12:42
                      0
                      • A Annabelle
                        24 Jul 2019, 12:22

                        @jsulm said in Qt Programming Language:

                        @Annabelle Looks good, it works

                        Cool-ee-o! So what do I do next?

                        A Offline
                        A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on 24 Jul 2019, 12:42 last edited by
                        #312

                        @Annabelle: Congrats, your program is compiling and running.

                        However, it does not seem to output any useful yet.

                        So the next thing would be to actually make your program to output "Hello World!" (or any other greeting you can think of).

                        Good luck!

                        Qt has to stay free or it will die.

                        A 1 Reply Last reply 24 Jul 2019, 13:13
                        2
                        • A aha_1980
                          24 Jul 2019, 12:42

                          @Annabelle: Congrats, your program is compiling and running.

                          However, it does not seem to output any useful yet.

                          So the next thing would be to actually make your program to output "Hello World!" (or any other greeting you can think of).

                          Good luck!

                          A Offline
                          A Offline
                          Annabelle
                          wrote on 24 Jul 2019, 13:13 last edited by
                          #313

                          @aha_1980 said in Qt Programming Language:

                          @Annabelle: Congrats, your program is compiling and running.

                          However, it does not seem to output any useful yet.

                          So the next thing would be to actually make your program to output "Hello World!" (or any other greeting you can think of).

                          Good luck!

                          Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                          A J 2 Replies Last reply 24 Jul 2019, 13:21
                          0
                          • A Annabelle
                            24 Jul 2019, 13:13

                            @aha_1980 said in Qt Programming Language:

                            @Annabelle: Congrats, your program is compiling and running.

                            However, it does not seem to output any useful yet.

                            So the next thing would be to actually make your program to output "Hello World!" (or any other greeting you can think of).

                            Good luck!

                            Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                            A Offline
                            A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on 24 Jul 2019, 13:21 last edited by
                            #314

                            Hi @Annabelle,

                            Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                            Yes, it is. Do you have this output somewhere on your screen? In the screenshots you provided, I didn't see it.

                            If you already have that, then the next steps could be:

                            1. Print "Hello World" ten times, with an upcounting number appended, like:
                            Hello World 1
                            Hello World 2
                            Hello World 3
                            ...
                            Hello World 10
                            
                            1. Ask the user for his name, and greet him. That could look like this:
                            Hello, what's your name?
                            Luke
                            Nice to meet you, Luke!
                            

                            That would then almost be a complete program, taking an input and providing an output. Only the data processing is missing - but we can add that later.

                            Regards

                            Qt has to stay free or it will die.

                            1 Reply Last reply
                            2
                            • A Annabelle
                              24 Jul 2019, 13:13

                              @aha_1980 said in Qt Programming Language:

                              @Annabelle: Congrats, your program is compiling and running.

                              However, it does not seem to output any useful yet.

                              So the next thing would be to actually make your program to output "Hello World!" (or any other greeting you can think of).

                              Good luck!

                              Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                              J Offline
                              J Offline
                              JonB
                              wrote on 24 Jul 2019, 15:07 last edited by JonB
                              #315

                              @Annabelle
                              Hi Annabelle.

                              Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                              As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                              If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                              A 2 Replies Last reply 25 Jul 2019, 03:40
                              1
                              • J JonB
                                24 Jul 2019, 15:07

                                @Annabelle
                                Hi Annabelle.

                                Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                                As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                                If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                                A Offline
                                A Offline
                                Annabelle
                                wrote on 25 Jul 2019, 03:40 last edited by
                                #316

                                @JonB said in Qt Programming Language:

                                @Annabelle
                                Hi Annabelle.

                                Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                                As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                                If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                                How's this?
                                0_1564026008478_a78a4405-c20a-4616-b15e-09d67a7e7238-image.png

                                1 Reply Last reply
                                0
                                • J JonB
                                  24 Jul 2019, 15:07

                                  @Annabelle
                                  Hi Annabelle.

                                  Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                                  As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                                  If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                                  A Offline
                                  A Offline
                                  Annabelle
                                  wrote on 25 Jul 2019, 03:45 last edited by
                                  #317

                                  @JonB said in Qt Programming Language:

                                  @Annabelle
                                  Hi Annabelle.

                                  Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                                  As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                                  If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                                  How about this one.
                                  0_1564026313636_ece6e8dd-5eed-4e06-92f8-909491c8ad37-image.png

                                  A J 2 Replies Last reply 25 Jul 2019, 06:14
                                  0
                                  • A Annabelle
                                    25 Jul 2019, 03:45

                                    @JonB said in Qt Programming Language:

                                    @Annabelle
                                    Hi Annabelle.

                                    Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                                    As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                                    If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                                    How about this one.
                                    0_1564026313636_ece6e8dd-5eed-4e06-92f8-909491c8ad37-image.png

                                    A Offline
                                    A Offline
                                    aha_1980
                                    Lifetime Qt Champion
                                    wrote on 25 Jul 2019, 06:14 last edited by
                                    #318

                                    Hi @Annabelle,

                                    Ok, that shows us your current main function. So far so good!

                                    What you did there, is called hardcoding. That means, your program does greet you, but it can only great you and no one else.

                                    Before we proceed I have an important question. When you run your program, do you get the greeting output on some window? That is an important point, because that's why we do all this programming, right?

                                    And once that is working the task is really, to not only greet Annabelle, but also Vladimir, Julia, Rodriguez, and Sabrina, ...

                                    To do this, you will need to get some input into your program, and store the input for further processing.

                                    Regards

                                    Qt has to stay free or it will die.

                                    1 Reply Last reply
                                    1
                                    • A Annabelle
                                      25 Jul 2019, 03:45

                                      @JonB said in Qt Programming Language:

                                      @Annabelle
                                      Hi Annabelle.

                                      Isn't that what the line, "std::cout << "Hello, World!"; is supposed to do? I'm confused!

                                      As I mentioned earlier, we cannot see your source code in the screenshots. You need to open your source file so that we at least can see its contents.

                                      If you were currently editing your .cpp file's content, I assume you have to have it open, e.g. so your screen reader can read its content. Can you get to that state and post screenshot?

                                      How about this one.
                                      0_1564026313636_ece6e8dd-5eed-4e06-92f8-909491c8ad37-image.png

                                      J Offline
                                      J Offline
                                      JonB
                                      wrote on 25 Jul 2019, 07:21 last edited by JonB
                                      #319

                                      @Annabelle
                                      Hi Annabelle,

                                      Yep, the latest screenshot allows us to see your code! You'll want to show us that when you have a question about your code. (At a later date if the code gets too long to show in that screen we'll have to do something else, but that can wait for now.)

                                      A couple of points:

                                      1. Earlier you had a compilation error, about a funny character in the code, at line #9, I believe. It seems to be compiling now, I think, so you may have dealt with that. But your lines 9, 10 and 11 are just an open-curly-brace, a blank line, and then a close-curly-brace. These do nothing, and are not useful in your code. Delete lines 9 to 11 inclusive, or replace them with a single blank line which looks nice to us (a gap between the #include line and the start of your main() function), but you may not be fussed about blank lines/layout.

                                      2. As @aha_1980 has written, your program produces some lines of output sent to what is called "stdout" via your std::cout lines. This should produce some output somewhere (which can presumably be read to you), but we cannot see where that might be. The development environment you are using, known as an "IDE", is in charge of where that goes.

                                      What we can see is that the "Build log" tab you are displaying, which shows the results of compiling, does not seem to include this output. Maybe there is a different tab at the bottom, scrolled off to the right, which has some sort of "Output" pane to send to? Or --- and it gets confusing now, I am only guessing --- the "Build log" seems to be showing that when your IDE runs your "Hello World" program it does it by passing it to an internal CodeBlocks or CodeRunner program named cb_console_runner.exe. Note the use of "console" there. It may be that opens up a "console" (like an output window) when it runs to display your program's output, and that might automatically go away when your program ends, I don't know.

                                      EDIT I think I now understand your IDE is Code::Blocks (not CodeRunner). I have done some brief Googling, which you may want to do, for CodeBlocks stdout. There are indeed various hits about "how do I get to see the output from my program from CodeBlocks".

                                      If we take, say, https://stackoverflow.com/questions/28878911/how-can-i-get-console-output-in-code-block-ide, the guy there has a similar program to yours. One thing we are told is

                                      Click on build->run or hit Ctrl+F10 and a new CMD Window should pop up, showing you your "Hello world!".

                                      So that tells us it does indeed need to open a separate command/output window to send the output to. Does your screenreader tell you this window gets opened or read its content?

                                      Then the last response there says:

                                      Please include getchar() in the function before return statement. This happens because the computer is executing your program and doesn't wait for you to see the output. Including getchar(), at the end mandates it to wait for an input & in the meanwhile you can observe your output

                                      I did wonder if this might be the case. Because your program outputs some lines and then simply terminates, it may well be that this console output window pops up when you run your program, shows the lines, and then immediately exits. So you/your screenreader may know nothing about it. You need to cause the program to "pause" before it exists so you can examine this output window.

                                      I'm not a C++ expert, but I believe you should try inserting the following two lines after all your std::cout lines and immediately before your return 0; line:

                                      std::string input;
                                      std::getline(std::cin, input);
                                      

                                      If you do that, when you run your program I believe/hope it will not immediately run to exit as it does now. You will have to "find" that new output window and click the Enter key in it before it exits and then your program completes. Hopefully you can then get your screenreader to read it out before you press the key?

                                      A 1 Reply Last reply 26 Jul 2019, 21:53
                                      4
                                      • J JonB
                                        25 Jul 2019, 07:21

                                        @Annabelle
                                        Hi Annabelle,

                                        Yep, the latest screenshot allows us to see your code! You'll want to show us that when you have a question about your code. (At a later date if the code gets too long to show in that screen we'll have to do something else, but that can wait for now.)

                                        A couple of points:

                                        1. Earlier you had a compilation error, about a funny character in the code, at line #9, I believe. It seems to be compiling now, I think, so you may have dealt with that. But your lines 9, 10 and 11 are just an open-curly-brace, a blank line, and then a close-curly-brace. These do nothing, and are not useful in your code. Delete lines 9 to 11 inclusive, or replace them with a single blank line which looks nice to us (a gap between the #include line and the start of your main() function), but you may not be fussed about blank lines/layout.

                                        2. As @aha_1980 has written, your program produces some lines of output sent to what is called "stdout" via your std::cout lines. This should produce some output somewhere (which can presumably be read to you), but we cannot see where that might be. The development environment you are using, known as an "IDE", is in charge of where that goes.

                                        What we can see is that the "Build log" tab you are displaying, which shows the results of compiling, does not seem to include this output. Maybe there is a different tab at the bottom, scrolled off to the right, which has some sort of "Output" pane to send to? Or --- and it gets confusing now, I am only guessing --- the "Build log" seems to be showing that when your IDE runs your "Hello World" program it does it by passing it to an internal CodeBlocks or CodeRunner program named cb_console_runner.exe. Note the use of "console" there. It may be that opens up a "console" (like an output window) when it runs to display your program's output, and that might automatically go away when your program ends, I don't know.

                                        EDIT I think I now understand your IDE is Code::Blocks (not CodeRunner). I have done some brief Googling, which you may want to do, for CodeBlocks stdout. There are indeed various hits about "how do I get to see the output from my program from CodeBlocks".

                                        If we take, say, https://stackoverflow.com/questions/28878911/how-can-i-get-console-output-in-code-block-ide, the guy there has a similar program to yours. One thing we are told is

                                        Click on build->run or hit Ctrl+F10 and a new CMD Window should pop up, showing you your "Hello world!".

                                        So that tells us it does indeed need to open a separate command/output window to send the output to. Does your screenreader tell you this window gets opened or read its content?

                                        Then the last response there says:

                                        Please include getchar() in the function before return statement. This happens because the computer is executing your program and doesn't wait for you to see the output. Including getchar(), at the end mandates it to wait for an input & in the meanwhile you can observe your output

                                        I did wonder if this might be the case. Because your program outputs some lines and then simply terminates, it may well be that this console output window pops up when you run your program, shows the lines, and then immediately exits. So you/your screenreader may know nothing about it. You need to cause the program to "pause" before it exists so you can examine this output window.

                                        I'm not a C++ expert, but I believe you should try inserting the following two lines after all your std::cout lines and immediately before your return 0; line:

                                        std::string input;
                                        std::getline(std::cin, input);
                                        

                                        If you do that, when you run your program I believe/hope it will not immediately run to exit as it does now. You will have to "find" that new output window and click the Enter key in it before it exits and then your program completes. Hopefully you can then get your screenreader to read it out before you press the key?

                                        A Offline
                                        A Offline
                                        Annabelle
                                        wrote on 26 Jul 2019, 21:53 last edited by
                                        #320

                                        @jonb said in Qt Programming Language:

                                        @Annabelle
                                        Hi Annabelle,

                                        Yep, the latest screenshot allows us to see your code! You'll want to show us that when you have a question about your code. (At a later date if the code gets too long to show in that screen we'll have to do something else, but that can wait for now.)

                                        A couple of points:

                                        1. Earlier you had a compilation error, about a funny character in the code, at line #9, I believe. It seems to be compiling now, I think, so you may have dealt with that. But your lines 9, 10 and 11 are just an open-curly-brace, a blank line, and then a close-curly-brace. These do nothing, and are not useful in your code. Delete lines 9 to 11 inclusive, or replace them with a single blank line which looks nice to us (a gap between the #include line and the start of your main() function), but you may not be fussed about blank lines/layout.

                                        2. As @aha_1980 has written, your program produces some lines of output sent to what is called "stdout" via your std::cout lines. This should produce some output somewhere (which can presumably be read to you), but we cannot see where that might be. The development environment you are using, known as an "IDE", is in charge of where that goes.

                                        What we can see is that the "Build log" tab you are displaying, which shows the results of compiling, does not seem to include this output. Maybe there is a different tab at the bottom, scrolled off to the right, which has some sort of "Output" pane to send to? Or --- and it gets confusing now, I am only guessing --- the "Build log" seems to be showing that when your IDE runs your "Hello World" program it does it by passing it to an internal CodeBlocks or CodeRunner program named cb_console_runner.exe. Note the use of "console" there. It may be that opens up a "console" (like an output window) when it runs to display your program's output, and that might automatically go away when your program ends, I don't know.

                                        EDIT I think I now understand your IDE is Code::Blocks (not CodeRunner). I have done some brief Googling, which you may want to do, for CodeBlocks stdout. There are indeed various hits about "how do I get to see the output from my program from CodeBlocks".

                                        If we take, say, https://stackoverflow.com/questions/28878911/how-can-i-get-console-output-in-code-block-ide, the guy there has a similar program to yours. One thing we are told is

                                        Click on build->run or hit Ctrl+F10 and a new CMD Window should pop up, showing you your "Hello world!".

                                        So that tells us it does indeed need to open a separate command/output window to send the output to. Does your screenreader tell you this window gets opened or read its content?

                                        Then the last response there says:

                                        Please include getchar() in the function before return statement. This happens because the computer is executing your program and doesn't wait for you to see the output. Including getchar(), at the end mandates it to wait for an input & in the meanwhile you can observe your output

                                        I did wonder if this might be the case. Because your program outputs some lines and then simply terminates, it may well be that this console output window pops up when you run your program, shows the lines, and then immediately exits. So you/your screenreader may know nothing about it. You need to cause the program to "pause" before it exists so you can examine this output window.

                                        I'm not a C++ expert, but I believe you should try inserting the following two lines after all your std::cout lines and immediately before your return 0; line:

                                        std::string input;
                                        std::getline(std::cin, input);
                                        

                                        If you do that, when you run your program I believe/hope it will not immediately run to exit as it does now. You will have to "find" that new output window and click the Enter key in it before it exits and then your program completes. Hopefully you can then get your screenreader to read it out before you press the key?

                                        Here's a screenshot of what my project looks like now.
                                        0_1564177921376_fab80b48-d5dd-4d3a-b0f7-08a520e8af57-image.png
                                        And here's a screenshot of the code.
                                        0_1564177954379_79727094-32ac-4da2-a426-6e8d36889568-image.png

                                        J A 2 Replies Last reply 27 Jul 2019, 09:08
                                        2
                                        • A Annabelle
                                          26 Jul 2019, 21:53

                                          @jonb said in Qt Programming Language:

                                          @Annabelle
                                          Hi Annabelle,

                                          Yep, the latest screenshot allows us to see your code! You'll want to show us that when you have a question about your code. (At a later date if the code gets too long to show in that screen we'll have to do something else, but that can wait for now.)

                                          A couple of points:

                                          1. Earlier you had a compilation error, about a funny character in the code, at line #9, I believe. It seems to be compiling now, I think, so you may have dealt with that. But your lines 9, 10 and 11 are just an open-curly-brace, a blank line, and then a close-curly-brace. These do nothing, and are not useful in your code. Delete lines 9 to 11 inclusive, or replace them with a single blank line which looks nice to us (a gap between the #include line and the start of your main() function), but you may not be fussed about blank lines/layout.

                                          2. As @aha_1980 has written, your program produces some lines of output sent to what is called "stdout" via your std::cout lines. This should produce some output somewhere (which can presumably be read to you), but we cannot see where that might be. The development environment you are using, known as an "IDE", is in charge of where that goes.

                                          What we can see is that the "Build log" tab you are displaying, which shows the results of compiling, does not seem to include this output. Maybe there is a different tab at the bottom, scrolled off to the right, which has some sort of "Output" pane to send to? Or --- and it gets confusing now, I am only guessing --- the "Build log" seems to be showing that when your IDE runs your "Hello World" program it does it by passing it to an internal CodeBlocks or CodeRunner program named cb_console_runner.exe. Note the use of "console" there. It may be that opens up a "console" (like an output window) when it runs to display your program's output, and that might automatically go away when your program ends, I don't know.

                                          EDIT I think I now understand your IDE is Code::Blocks (not CodeRunner). I have done some brief Googling, which you may want to do, for CodeBlocks stdout. There are indeed various hits about "how do I get to see the output from my program from CodeBlocks".

                                          If we take, say, https://stackoverflow.com/questions/28878911/how-can-i-get-console-output-in-code-block-ide, the guy there has a similar program to yours. One thing we are told is

                                          Click on build->run or hit Ctrl+F10 and a new CMD Window should pop up, showing you your "Hello world!".

                                          So that tells us it does indeed need to open a separate command/output window to send the output to. Does your screenreader tell you this window gets opened or read its content?

                                          Then the last response there says:

                                          Please include getchar() in the function before return statement. This happens because the computer is executing your program and doesn't wait for you to see the output. Including getchar(), at the end mandates it to wait for an input & in the meanwhile you can observe your output

                                          I did wonder if this might be the case. Because your program outputs some lines and then simply terminates, it may well be that this console output window pops up when you run your program, shows the lines, and then immediately exits. So you/your screenreader may know nothing about it. You need to cause the program to "pause" before it exists so you can examine this output window.

                                          I'm not a C++ expert, but I believe you should try inserting the following two lines after all your std::cout lines and immediately before your return 0; line:

                                          std::string input;
                                          std::getline(std::cin, input);
                                          

                                          If you do that, when you run your program I believe/hope it will not immediately run to exit as it does now. You will have to "find" that new output window and click the Enter key in it before it exits and then your program completes. Hopefully you can then get your screenreader to read it out before you press the key?

                                          Here's a screenshot of what my project looks like now.
                                          0_1564177921376_fab80b48-d5dd-4d3a-b0f7-08a520e8af57-image.png
                                          And here's a screenshot of the code.
                                          0_1564177954379_79727094-32ac-4da2-a426-6e8d36889568-image.png

                                          J Offline
                                          J Offline
                                          JonB
                                          wrote on 27 Jul 2019, 09:08 last edited by JonB
                                          #321

                                          @annabelle
                                          There you are, you've found the command window it sends its output to, and made it wait to exit till you press Enter, so you have time to read the output!

                                          However, I don't think your output can correspond exactly to what you have shown as your current program code in the screenshot? Two reasons:

                                          • Your output shows only Hello world!. But your code has 4 lines of output statements, we are not seeing the last 3 of them.

                                          • At line 18 you have the close-curly-brace to mark the end of your main() function definition. But I do not see the open-curly-brace to start the block? You should have an open-curly-brace after line 10 (int main()) and before line 11? That should mean the code you show does not compile.

                                          Your Build log window shows it running the Hello World.exe executable but it does not show it compiling the source. Do you actually have an old Hello World.exe executable sitting there from a previous, successful build against different source, which is what it is running?

                                          EDIT Aha! I can see in your IDE the title of the tab you are showing reads:

                                          *Hello Word!.cpp
                                          

                                          Note that * (asterisk) at the start of the filename. Editors do that to indicate that you have altered the text of the file in the editor pane but you have not saved it back to the file. That means the code as you show it has not been passed to the compiler, and it is indeed running the executable (no re-compilation) that was last successfully compiled. If you make/made the open-curly-brace change I said then this code would compile, and produce 4 lines of output.

                                          BTW: I'm not sure, but when I looked for you at what people were saying about this output window from CodeBlocks I think someone was claiming that in one of its "settings" (available somewhere inside the IDE) there is some kind of "Pause [for key press] at end of program before closing command output window". If you can find that you could avoid having to put the std::getline() at the end of your program.

                                          1 Reply Last reply
                                          1

                                          311/331

                                          24 Jul 2019, 12:22

                                          • Login

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