-
wrote on 22 Mar 2017, 18:45 last edited by itzalak2
Hi all,
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.
The program:
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32 //
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// enter the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius:";
cin >> celsius;
// calculate conversion factor for Celsius to Fahrenheit
int factor;
factor = 212 - 32;
// use conversion factor to convert Celsius into Fahrenheit values
int fahrenheit;
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”);
return 0;
} -
Hi and welcome to devnet,
What do you mean by console ?
-
wrote on 23 Mar 2017, 10:00 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);
-
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.
-
wrote on 24 Mar 2017, 09:12 last edited by itzalak2
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.
-
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.
-
wrote on 24 Mar 2017, 09:45 last edited by itzalak2
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.
-
wrote on 20 Mar 2022, 12:16 last edited by
Hello! I have similar problem, I checked terminal and getting this error
Please advise how to fix:
:-1: error: cannot open output file release\writeToDat.exe: Permission denied -
Hello! I have similar problem, I checked terminal and getting this error
Please advise how to fix:
:-1: error: cannot open output file release\writeToDat.exe: Permission deniedwrote on 20 Mar 2022, 12:24 last edited by JonB@icebergenergy
Doesn't sound like anything related to this issue.
Assumingrelease\writeToDat.exe
is your executable and the right path to it, have you looked to see whether you already have that executable running, perhaps left over from when you ran it outside of Creator? Use Task Manager to have a look at what processes are running. Restart your PC and see whether error has gone away. -
wrote on 20 Mar 2022, 13:02 last edited by
yeah! Already solved. Thanks. I had run it without building