#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;
}
이 프로그램에서는 입력 창 (do-while 루프의 4 번째 줄)에 취소 단추가 없습니다. 어떻게해야합니까? 방금 QT를 배우기 시작했습니다. 죄송합니다. 매우 근본적인 질문 인 경우.QInputDialog에서 "취소"버튼을 숨기려면 어떻게해야합니까?
또한 취소 버튼을 사용하여 응용 프로그램을 중지하는 방법은 무엇입니까? Bcos, 지금 CANCEL 버튼은 아무 것도하지 않습니다.
고맙습니다. 제이슨. 나는 내가 원하는 것을 얻었다. 또한, 나는이 bool * 매개 변수 개념을 제거했습니다. 실제로, 그것은 학습의 단지 두 번째 날입니다. –