当使用QFileDialog保存文件并指定扩展(如* .PDF)和在名称的用户类型,而该扩展,也已保存的文件还没有这个扩展。结果 实施例-代码:

QFileDialog fileDialog(this, "Choose file to save");
fileDialog.setNameFilter("PDF-Files (*.pdf)");
fileDialog.exec();
QFile pdfFile(fileDialog.selectedFiles().first());

现在,当用户输入“foo”的作为名称,该文件将被保存为“foo”的,不作为“foo.pdf”。所以QFileDialog不会自动添加扩展名。我的问题:我怎样才能改变这种

scroll top