0

我的程序(如下)可以编译,但不允许我输入值。我查看了许多线程,说明从运行中单击终端框,但这只会弹出一个窗口,说明“按下以关闭此窗口”,这确实违背了目的。对此的任何帮助都会很棒。谢谢

#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;
}
4

1 回答 1

1

如果您需要使用终端运行程序,这里已解决:Console input with Qt Creator

至少它对我有用。

于 2013-01-19T03:26:05.643 回答