Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Cin doesn't work in console but works correctly with terminal in OSX. (QT 5.8)
I'm new to QT and I'm trying simple examples to practice with this great tool.
After some work with this tool I have a "simple" problem with the the console and cin.
I did a simple program where I have to input a number (Celsius degree) and the program converts to Fahrenheit after I press ENTER key.
The program runs perfectly if I use the terminal of OSX SIERRA but if I use the console, cout shows a message correctly to enter a number but after I do it and press the enter key the program doesn't return the result and "freezes".
Is there any way to use the console instead the terminal of OS X?
Thanks in advance.
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32 //
using namespace std;
int main(int nNumberofArgs, char* pszArgs)
// enter the temperature in Celsius
cout << "Enter the temperature in Celsius:";
cin >> celsius;
// calculate conversion factor for Celsius to Fahrenheit
factor = 212 - 32;
// use conversion factor to convert Celsius into Fahrenheit values
fahrenheit = factor * celsius/100 + 32;
// output the results (followed by a NewLine)
cout << "Fahrenheit value is:";
cout << fahrenheit << endl;
// wait until user is ready before terminating program to allow the user to see the program results system(“PAUSE”);
Hi and welcome to devnet,
What do you mean by console ?
VRonin last edited by
Just for curiosity, could you add
#include <string>and try:
// enter the temperature in Celsius int celsius; string celsiusString; cout << "Enter the temperature in Celsius:"; getline(cin,celsiusString); celsius = stoi(celsiusString);
itzalak2 last edited by
With console I mean the application output of QT.
As I said it shows the text "Enter the temperature in Celsius:" correctly but doesn't do nothing when I write a number and press enter key.
@itzalak2 As far as I know you cannot enter there anything. Check the "Run in terminal" checkbox in Run settings of your project.
Thanks to all. Definitively you can't input anything through the console so I have to use the terminal.
One thing I find horrible is that when I run a simple app, QT launches the terminal but there is a very long message and I was asking if there is a way to avoid it.
I attach a capture, there you can see what shows the terminal when is launched by QT.
@itzalak2 What is the problem with this message? It is just what QtCreator is doing in the terminal to start your app. It will not be there if you start your app manually.
Yes, I know, but I would like not to show this loooooong message because it fills the 50% of the terminal screen. Is it possible to hide this message?
Thanks for the help.
Like @jsulm wrote, it won't appear if you run it from a normal terminal.