QFile f("D:\\测试数据\\单波束数据\\灯浮.TGT"); if (!f.open(QIODevice::ReadOnly|QIODevice::Text))//打开指定文件 { QMessageBox::about(NULL, "文件", "文件打开失败"); } QTextStream txtInput(&f); QString lineStr; while (!txtInput.atEnd()) { lineStr = txtInput.readLine(); //读取数据 QMessageBox::about(NULL, "字段数据", lineStr); } f.close();
【转】:https://blog.csdn.net/Giser_D/article/details/83149696