[Moved] QT and data input in ubuntu terminal
Page |
1 |
When I start a simple program that needs to input data in terminal (Ubuntu) – I can`t do it. In the console window i can input everything but the programm doesn`t respond.
Please tell me what is wrong?
25 replies
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]
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]
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.
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)
You must log in to post a reply. Not a member yet? Register here!



