我正在學習QT這些天,我想測試while while循環,實際的登錄工作正常,但在QT應用程序凍結.. 我已經定義了randnum和猜測在頭文件(public )QT做while循環
void MainWindow::on_pushButton_clicked()
{
srand (time(NULL));
randnum = rand() % 10 +1;
do {
guess = ui->spinBox->value();
if (guess < randnum)
{
ui->label->setText("try something big");
}
else if (guess > randnum)
{
ui->label->setText("try something small");
}
else
ui->label->setText("YAY?");
} while (guess != randnum);
}
請告訴我如何找到它凍結的原因..謝謝!
建議:使用qrand而非rand,請參閱:http://doc.qt.nokia.com/latest/qtglobal.html#qrand – snoofkin 2011-04-21 00:52:07