我在编一个程序,用qt3.x,用来读取文件夹中的txt文件,已知文件夹里有message0.txt,message1.txt,message2.txt,message3.txt,message4.txt等文件,要用一个pre,和next的外部按钮函数来实现,然后放到QMultiLineEdit编辑框里显示,我设了一个num变量用来放递增递减数,代表0,1,2,3,4等,int num。
void MyMainWindow::pre()
{
if ( num <= 0 )
return;
num--;
QFile myFile(("msg(num).txt"));
myFile.open(IO_ReadOnly);
QTextStream myStream(&myFile);
QString myString;
while(myStream.atEnd()==0)
{
myString=myStream.readLine();
medit->insertLine(myString);
}
myFile.close();
}
为什么编译通过,但实现不了我的功能,如果换成 QFile myFile(("msg0.txt")); 或QFile myFile(("msg1.txt")); 等就能显示,不知道怎么回事,变量能不能那样表示的啊?
[ 此贴被XChinux在2008-07-18 10:23重新编辑 ]