Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建然后使用 QTextStream 写入文本文件。问题是,如果我构建应用程序并从它创建的文件夹运行它,则会创建该文件,但如果我从 Qt 内部以发布或调试模式运行它,它不会创建该文件。有没有人有什么建议?我正在使用 Macbook Pro。
您可能使用了相对路径,并且在 QtCreator 中,运行可执行文件的“当前目录”不一定是可执行文件所在的目录。
尝试:
qDebug() << QDir::currentPath();
它会告诉您应该将文件写入何处。