2009-09-11 15 views
0
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 從上面的鏈接原來...在QT基本疑問使用C++約使物體

你能不能幫我出「QInputDialog ..(4號線做while循環)」我怎麼了解它有哪些參數? 我看到了文檔,但我無法找到,這是什麼這個「0」和「1」的論點..

回答

5

Read the docs。基本上 - 首先是一個父窗口小部件(在這種情況下是NULL),後面的1是默認值。