使用C ++制作对象的QT基本存在疑问

时间:2009-09-11 19:38:19

标签: c++ qt4

int main (int argc, char* argv[]) 
{ 
    QApplication app(argc, argv); 
    QTextStream cout(stdout, QIODevice::WriteOnly);     

    // Declarations of variables
    int answer = 0; 

    do {
        // local variables to the loop:
        int factArg = 0;
        int fact(1);
        factArg = QInputDialog::getInteger(0, "Factorial Calculator",
            "Factorial of:", 1);
        cout << "User entered: " << factArg << endl;
        int i=2;
        while (i <= factArg) {
            fact = fact * i;
            ++i;
        }
        QString response = QString("The factorial of %1 is %2.\n%3")
            .arg(factArg).arg(fact)  
            .arg("Do you want to compute another factorial?");    
        answer = QMessageBox::question(0, "Play again?", response,
            QMessageBox::Yes | QMessageBox::No); 
    } while (answer == QMessageBox::Yes);
    return EXIT_SUCCESS;
}

Link taken from here 最初来自上面的链接...

你能帮我解决“QInputDialog ..(第4行do while循环)”我怎样才能知道它有哪些参数? 我看到了文档,但我无法找到,参数中的“0”和“1”是什么。

1 个答案:

答案 0 :(得分:5)

Read the docs。基本上 - 首先是父窗口小部件(在这种情况下为NULL),标签后面的1是默认值。