#include <QtGui>
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:");
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 ,QMessageBox::Yes);
} while (answer == QMessageBox::Yes);
return EXIT_SUCCESS;
}
在這個程序中,我沒有輸入窗口(第4行do-while循環)有取消按鈕。我怎麼做? 我剛開始學習QT。所以,如果它是一個非常基本的問題,很抱歉如何使用C++在QT中隱藏QInputDialog中的「取消」按鈕?
而且我該如何利用取消按鈕來停止應用程序.. Bcos,現在取消按鈕什麼也不做。
Thanx Jason。我得到了我想要的東西。另外,我清除了這個bool *參數的概念。其實,這只是我第二天的學習。 – 2009-09-12 14:03:26