String[] s={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
Systemoutprint("请输入数字(1-12):");
BufferedReader br=new BufferedReader(new InputStreamReader(Systemin));
String str=brreadLine();
int m=IntegerparseInt(str);
if (m<=0||m>=13)
{
据我所知,QTextString这个类貌似是不存在的。倒是有个QTextStream类可以用来读取文本数据。
例如下面的函数可以读取小文本文件中的内容
void MainWindow::readFile(const QString& fpath)
{
if(fpathisEmpty())
return;
QFile file(fpath);
if(!fileopen(QIODevice::ReadOnly|QIODevice::Text))
{
qDebug()<<"Open file failure!";
return;
}
QTextStream fs(&file);
QString fileContent (fsreadAll());
qDebug()<<"The content of file is \n"<<fileContent;
}
你需要确保你将正确的文件路径传递给了该函数,否则会导致打开文件失败。
以上就是关于QT编程 获取当前工作目录下的文件列表,并以Tree的形式显示在界面上全部的内容,包括:QT编程 获取当前工作目录下的文件列表,并以Tree的形式显示在界面上、QT读取文本文件、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)