#include <QFile> #include <QTextStream>
QFile data("output.txt"); //建立output.txt if(data.open(QFile::WriteOnly | QFile::Truncate)){ //以只寫方式打開 | 刪除以前打開的設備以創建新的鏈接 QTextStream out(&data); out << "Result:" <<qSetFieldWidth(10) << left << 3.14 << 2.7; }