跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • 使用者
  • 群組
  • 搜尋
  • Get Qt Extensions
  • Unsolved
Collapse
品牌標誌
  1. 首頁
  2. Qt Development
  3. General and Desktop
  4. Qt Programming Language
Forum Updated to NodeBB v4.3 + New Features

Qt Programming Language

已排程 已置頂 已鎖定 已移動 Unsolved General and Desktop
331 貼文 17 Posters 380.4k 瀏覽 9 Watching
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • JKSHJ JKSH

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

    A 離線
    A 離線
    Annabelle
    寫於 最後由 編輯
    #301

    @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

    JonBJ JKSHJ 2 條回覆 最後回覆
    0
    • A Annabelle

      @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

      JonBJ 線上
      JonBJ 線上
      JonB
      寫於 最後由 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 條回覆 最後回覆
      3
      • A Annabelle

        @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

        JKSHJ 離線
        JKSHJ 離線
        JKSH
        Moderators
        寫於 最後由 編輯
        #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 條回覆 最後回覆
        4
        • JKSHJ JKSH

          @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 離線
          A 離線
          Annabelle
          寫於 最後由 編輯
          #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!

          JKSHJ 1 條回覆 最後回覆
          0
          • A Annabelle

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

            JKSHJ 離線
            JKSHJ 離線
            JKSH
            Moderators
            寫於 最後由 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 條回覆 最後回覆
            4
            • JKSHJ JKSH

              @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 離線
              A 離線
              Annabelle
              寫於 最後由 編輯
              #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

              jsulmJ 1 條回覆 最後回覆
              2
              • A Annabelle

                @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

                jsulmJ 離線
                jsulmJ 離線
                jsulm
                Lifetime Qt Champion
                寫於 最後由 編輯
                #307

                @Annabelle Looks good, it works

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

                A 1 條回覆 最後回覆
                2
                • ODБOïO 離線
                  ODБOïO 離線
                  ODБOï
                  寫於 最後由 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.

                  mrjjM 1 條回覆 最後回覆
                  0
                  • ODБOïO ODБOï

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

                    mrjjM 離線
                    mrjjM 離線
                    mrjj
                    Lifetime Qt Champion
                    寫於 最後由 編輯
                    #309

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

                    ODБOïO 1 條回覆 最後回覆
                    2
                    • mrjjM mrjj

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

                      ODБOïO 離線
                      ODБOïO 離線
                      ODБOï
                      寫於 最後由 編輯
                      #310

                      @mrjj ah ok! my bad

                      1 條回覆 最後回覆
                      1
                      • jsulmJ jsulm

                        @Annabelle Looks good, it works

                        A 離線
                        A 離線
                        Annabelle
                        寫於 最後由 編輯
                        #311

                        @jsulm said in Qt Programming Language:

                        @Annabelle Looks good, it works

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

                        aha_1980A 1 條回覆 最後回覆
                        0
                        • A Annabelle

                          @jsulm said in Qt Programming Language:

                          @Annabelle Looks good, it works

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

                          aha_1980A 離線
                          aha_1980A 離線
                          aha_1980
                          Lifetime Qt Champion
                          寫於 最後由 編輯
                          #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 條回覆 最後回覆
                          2
                          • aha_1980A aha_1980

                            @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 離線
                            A 離線
                            Annabelle
                            寫於 最後由 編輯
                            #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!

                            aha_1980A JonBJ 2 條回覆 最後回覆
                            0
                            • A Annabelle

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

                              aha_1980A 離線
                              aha_1980A 離線
                              aha_1980
                              Lifetime Qt Champion
                              寫於 最後由 編輯
                              #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 條回覆 最後回覆
                              2
                              • A Annabelle

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

                                JonBJ 線上
                                JonBJ 線上
                                JonB
                                寫於 最後由 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 條回覆 最後回覆
                                1
                                • JonBJ JonB

                                  @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 離線
                                  A 離線
                                  Annabelle
                                  寫於 最後由 編輯
                                  #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 條回覆 最後回覆
                                  0
                                  • JonBJ JonB

                                    @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 離線
                                    A 離線
                                    Annabelle
                                    寫於 最後由 編輯
                                    #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

                                    aha_1980A JonBJ 2 條回覆 最後回覆
                                    0
                                    • A Annabelle

                                      @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

                                      aha_1980A 離線
                                      aha_1980A 離線
                                      aha_1980
                                      Lifetime Qt Champion
                                      寫於 最後由 編輯
                                      #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 條回覆 最後回覆
                                      1
                                      • A Annabelle

                                        @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

                                        JonBJ 線上
                                        JonBJ 線上
                                        JonB
                                        寫於 最後由 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 條回覆 最後回覆
                                        4
                                        • JonBJ JonB

                                          @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 離線
                                          A 離線
                                          Annabelle
                                          寫於 最後由 編輯
                                          #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

                                          JonBJ aha_1980A 2 條回覆 最後回覆
                                          2

                                          • 登入

                                          • Login or register to search.
                                          • 第一個貼文
                                            最後的貼文
                                          0
                                          • 版面
                                          • 最新
                                          • 標籤
                                          • 熱門
                                          • 使用者
                                          • 群組
                                          • 搜尋
                                          • Get Qt Extensions
                                          • Unsolved