#includeQTemporaryFile file("example.txt"); if (file.open()) { // Do something with the file file.write("Hello, world!"); }
#includeIn this example, a QTemporaryFile object is created without a specified filename. A unique filename will be generated automatically. If the file opens successfully, the text "Hello, world!" is written to it. Package Library: Qt 5 Core Module Library.QTemporaryFile file; if (file.open()) { // Do something with the file file.write("Hello, world!"); }