문제

How can I read only first word in every line in a text file while using QFile in Qt? Thanks.

도움이 되었습니까?

해결책

use

    QFile ifile("in.txt");
    QString text = txStream.readLine();
    QStringList splitline = text.split(" ");
    QFile ofile("out.txt");
    ofile.open(QIODevice::WriteOnly | QIODevice::Text);

     QTextStream out(&ofile);

     // join QStringList by "\n" to write each single word in an own line
     out << splitline.join("\n");

     ofile.close(); 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top