このコードが終了すると、私の QTextStream は空です:
QString line1 = "This is line one";
QString line2 = "This is line two";
QString line3 = "This is line three";
QString outputFilename = "temp.txt";
QFile outputFile(outputFilename);
outputFile.open(QIODevice::WriteOnly);
outputFile.open(QIODevice::ReadWrite); // This fixes the problem
QTextStream out1(&outputFile);
out1 << line1 << endl;
out1 << line2 << endl;
out1 << line3 << endl;
outputFile.flush();
QString temp = out1.readAll();
mainclipboard->setText(temp);
outputFile.close();
ここで、QString temp は空です。私は何を逃したのですか?
答えてくれたハイドに感謝します。