No actions in Qt, after I entered the Cin() data.
-
#include <iostream> int main() { // An example that illustrates using the arithmetic operators: // define variables: unsigned int yards {}, feet {}, inches {}; // Convert a distance in yards,feet and inches to inches std::cout << "Enter a distance as yards,feet and inches" << " with the three values separated by spaces:" << std::endl; std::cin >> yards >> feet >> inches; // define constants const unsigned feet_per_yard {3}; const unsigned inches_per_feet {12}; // define other formulations and elements unsigned total_inches {}; total_inches = inches + inches_per_feet * (yards * feet_per_yard +feet); std::cout << "The distances corresponds to " << total_inches << " inches.\n"; // Convert a distance in inches to yards feet and inches std::cout << "Rnter a distance in inches: "; std::cin >> total_inches; // define other formulations and elements feet = total_inches / inches_per_feet; inches = total_inches % inches_per_feet; yards = feet / feet_per_yard; feet = feet % feet_per_yard; std::cout << "The distance corresponds to" << yards << " yards" << feet << " feet" << inches << " inches." << std::endl; }
It runs well in Visual Studio.but not in Qt.
after I entered the Cin() need data:1(space)2(space)3(enter key),then the cursor stopped when it moved to the second line...
what is the wrong with this ?Thx. -
@mgstanley Your code works fine for me when I build and run it with MinGW 7.3.0 in Qt Creator.
How are you configuring your project? If you use qmake, make sure you have
CONFIG += console
in your .pro file. -
@mgstanley said in No actions in Qt, after I entered the Cin() data.:
but where can find the .pro file?
Inside your project folder
-
This post is deleted!
-
@jsulm Thx, but awkward situation is, I still cannot find *.pro file in all the newly built Qt console application project, except in Qt widgets application project.
And the *.pro file in Qt widgets application project, still does not work after I added CONFIG += console sentence in......☹
-
@mgstanley said in No actions in Qt, after I entered the Cin() data.:
I still cannot find *.pro file in all the newly built Qt console application project
What build system did you choose for your projects: qmake, or CMake, or qbs?
.pro files are used by qmake only.
And the *.pro file in Qt widgets application project, still does not work after I added CONFIG += console sentence in......☹
Well, a widgets project should not have a console...
-
@mgstanley And you did a complete rebuild of your app after changing pro file (delete build folder, run qmake, build)?
-
@mgstanley You can see the build folder in project settings in QtCreator. Usually it is net to project folder (but not inside the project folder).