简体   繁体   中英

Running qt terminal for windows 7

My program (below) compiles but it will not allow me to enter the values. I've looked at many threads stating to click the terminal box from run but that only brings up a window stating "Press to close this window," which really defeats the purpose. Any help on this would be great. Thanks

#include <QCoreApplication>
#include <QTextStream>


//using namespace std;
QTextStream cin(stdin);
QTextStream cout(stdout);

int main()
{
    QString firstName;
    QString lastName;
    QString houseNumber;
    QString streetName;
    QString streetType;
    QString city;
    QString state;
    QString zipCode;
    QString phone;

    cout<<"Please enter your first name:  " << endl;
    cin >> firstName;
    cout << endl <<"Please enter your first name:  " << endl;
    cin >> lastName;

    cout << endl <<"Please enter your house number:  " << endl;
    cin >> houseNumber;

    cout << endl <<"Please enter your street Name:  " << endl;
    cin >> streetName;

    cout << endl <<"Please enter your street type (i.e. Rd, St, Blvd, ect):  ";
    cin >> streetType;

    cout << endl <<"Please enter your city:  " << endl;
    cin >> city;

    cout << endl <<"Please enter your state:  " << endl;
    cin >> state;

    cout << endl <<"Please enter your zip code:  " << endl;
    cin >> zipCode;

    cout << endl <<"Please enter your phone number:  " << endl;
    cin >> phone;


    cout << endl << "Your information is:  " << endl << endl;
    cout << firstName <<" "<<lastName<<endl;
    cout << houseNumber << " " << streetName << " " << streetType << endl;
    cout << city << ", " << state << "  " << zipCode << endl;
    cout << "Phone Number:  " << phone << endl << endl;

    return 0;
}

If you need to run the program with a terminal it has been solved here: Console input with Qt Creator

At least it worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM