我正在学习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