Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Moved] QT and data input in ubuntu terminal

[Moved] QT and data input in ubuntu terminal

Scheduled Pinned Locked Moved Qt Creator and other tools
27 Posts 5 Posters 13.1k 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.
  • D Offline
    D Offline
    denya
    wrote on last edited by
    #1

    When I start a simple program that needs to input data in terminal (Ubuntu) - I cant do it. In the console window i can input everything but the programm doesnt respond.
    Please tell me what is wrong?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Probably your code is wrong.

      Sorry, that's much too less information to give you a reasonable answer. You can provide us the source code for a

      • short
      • complete
      • compilable
      • runnable

      program that demonstrates us the problem and we'll have a look.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        denya
        wrote on last edited by
        #3

        Here is the code:

        @
        #include <iostream>
        using namespace std;
        #include <cctype>

        int fuct (int);

        int main()
        {
        int n;

            cout << "Input number: ";
            while (cin >> n)
            {
                    int fk = fuct (n);
                    cout << "\nFactorial: " << fk << "\n";
                    cout << "Input number: ";
            }
        
            return 0;
        

        }

        int fuct (int n)
        {
        if (n == 0) return 1;
        else if (n == 1) return 1;
        else return n * fuct(n-1);
        }
        @

        [EDIT: code formatting, please use @-tags, Volker]

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          How does this code relate to Qt?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            denya
            wrote on last edited by
            #5

            Sorry, the code was displayed wrong in the previous post:

            @
            #include <iostream>
            using namespace std;
            #include <cctype>

            int fuct (int);

            int main()
            {
            int n;

                cout << "Input number: ";
                while (cin >> n)
                {
                        int fk = fuct (n);
                        cout << "\nFactorial: " << fk << "\n";
                        cout << "Input number: ";
                }
            
                return 0;
            

            }

            int fuct (int n)
            {
            if (n == 0) return 1;
            else if (n == 1) return 1;
            else return n * fuct(n-1);
            }
            @

            [EDIT: code formatting, Volker]

            1 Reply Last reply
            0
            • D Offline
              D Offline
              denya
              wrote on last edited by
              #6

              so, if it has not relation to Qt it will not work properly?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                Nothing is wrong, it works for me.

                Also this has nothing to do with Qt.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  denya
                  wrote on last edited by
                  #8

                  I have understood about Qt, but input data doesn`t work in the console:


                  Launching /home/denis/tutorial-build-desktop/tutorial...
                  Input number: 1

                  1
                  2
                  2w

                  d
                  c

                  I can input everything and the programm doesn`t have any reaction.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    denya
                    wrote on last edited by
                    #9

                    The debugger wrote:

                    &"warning: GDB: Failed to set controlling terminal: \320\235\320\265\320\264\320\276\320\277\321\203\321\201\321\202\320\270\320\274\321\213\320\271 \320\260\321\200\320\263\321\203\320\274\320\265\320\275\321\202\n"

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      If you have a console application that reads from the console then please do start it on the console and neither in a debugger nor in your IDE.

                      EDIT: PS: If you had provided us that information before, you would have got an answer.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        Moved to tools forum, as it seems to be an issue with how to use Qt Creator properly.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by
                          #12

                          Hi, Volker -

                          So, do I understand from your post above that if a program needs console input, we can't/shouldn't launch it from Creator?

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on last edited by
                            #13

                            At least it's hard to debug, because you have no means to input your data (at least I'm not aware of one), so your program hangs once it tries to read from stdin.

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0
                            • mzimmersM Offline
                              mzimmersM Offline
                              mzimmers
                              wrote on last edited by
                              #14

                              OK, thanks. I suppose that, given that Qt is a GUI development system, this is reasonable, though it may surprise some people who come from a more conventional IDE like Eclipse.

                              Is there at least a way to launch the terminal from Qt? Some minor level of integration would make it a little easier.

                              EDIT: let me rephrase that: there does appear to be some kind of terminal integration (though I can't get it to work for me); can one launch an app to terminal from Qt while still controlling the app through the Qt debugger? That would be slick.

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on last edited by
                                #15

                                It's not a problem of GUI or console development. You can have console input on a GUI program too :-)

                                Ah, seems that I was wrong!

                                In the run settings (project view of Creator) you can check a checkbox "run in terminal", this might be what you want. It's a bit cumbersome on the mac though (I remember you being on OS X, right?). You must set the terminal application on the mac to

                                /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal

                                (Settings, Environment, first tab)

                                http://www.catb.org/~esr/faqs/smart-questions.html

                                1 Reply Last reply
                                0
                                • mzimmersM Offline
                                  mzimmersM Offline
                                  mzimmers
                                  wrote on last edited by
                                  #16

                                  That sure seems like it should work, doesn't it? But, when I try to start a debug session, I get an error message at launch, saying it can't start the terminal emulator '/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal'. Dunno...

                                  1 Reply Last reply
                                  0
                                  • T Offline
                                    T Offline
                                    tobias.hunger
                                    wrote on last edited by
                                    #17

                                    There actually is a "launch in terminal" in the run settings of your project in Qt Creator... Go to project mode and visit the run settings there.

                                    1 Reply Last reply
                                    0
                                    • mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #18

                                      I assume you mean the "Run in terminal" check box? I have that checked. Still doesn't go.

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on last edited by
                                        #19

                                        [quote author="mzimmers" date="1302358795"]That sure seems like it should work, doesn't it? But, when I try to start a debug session, I get an error message at launch, saying it can't start the terminal emulator '/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal'. Dunno...
                                        [/quote]

                                        This should work. Where is your Terminal.app located? You'll need to enter

                                        /path/to/Terminal.app/Contents/MacOS/Terminal

                                        into the config field.

                                        EDIT: You actually are on a Mac, aren't you?

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 Reply Last reply
                                        0
                                        • mzimmersM Offline
                                          mzimmersM Offline
                                          mzimmers
                                          wrote on last edited by
                                          #20

                                          Heh...yes, I'm on a Mac, and the path you provided above is indeed the correct one. No idea why it's not working.

                                          1 Reply Last reply
                                          0

                                          • Login

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