我现在想读取文件中的值以初始化按钮上的文本,但是什么也读不出来,执行完下面的语句后,按钮上什么也没有,到底是为什么阿?请大家帮帮忙,多谢
QFile file( "pwd.dat" );
if (! file.open( IO_ReadOnly ) ) { QMessageBox *mb=new QMessageBox("","The file can't be opened!",QMessageBox::Critical,QMessageBox::Ok,0,0);
mb->show();
}
if ( file.open( IO_ReadOnly ) ) {
QTextStream stream( &file );
while ( !stream.atEnd() ) {
password = stream.readLine();}
file.close();
}
buttonOk->setText(password);
PS:在pwd.dat中已经预存了字符串。字符串我是用键盘输入的,是不是因此不能读取阿?
[ 此帖被yanjinchen在2009-07-04 11:10重新编辑 ]