如何创建新的'doc'和'docx'文件,并在Windows的'qt'中使用'QAxObjectin'编写文本。我尝试使用“ https://forum.qt.io/topic/74254/how-to-read-and-write-docx-files-in-qt”,但找不到答案,因为它打开了现有文件,但我想创建一个新文件。
您可以使用您提到的链接中的代码,而无需做任何修改:
QFile fileout("abc.docx");
if(!fileout.open(QFile::WriteOnly | QFile::Text))
qDebug()<< "Could not open file";
QTextStream out(&fileout);
QString text = "hello world";
out << text;
fileout.flush();
fileout.close();
这是您需要的吗?