简体   繁体   中英

Basic doubt in QT using C++ about making objects

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 originally from above link...

Can you help me out with "QInputDialog..(4th line of do while loop)" How do I get to know about which arguments does it have? I saw the documentation but i couldnt find out, whats this "0" and "1" in arguments..

Read the docs . Basically - first is a parent widget (NULL in this case), and the 1 after label is a default value.

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