Doute de base dans QT utilisant C ++ pour créer des objets
Question
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;
}
Lien à partir d'ici à l'origine du lien ci-dessus ...
Pouvez-vous m'aider avec " QInputDialog .. (4ème ligne de la boucle Do While) " Comment puis-je savoir quels arguments ont-ils? J'ai vu la documentation, mais je ne pouvais pas savoir ce que c'était "0". et "1" en arguments ..
La solution
Lisez la documentation . Fondamentalement, le premier est un widget parent (NULL dans ce cas) et le libellé 1 après est une valeur par défaut.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow