Qt编程技巧 QFileDialog自动添文件后缀的方法 Posted on 2009-10-26 In 技术笔记 123456QString filename;filename = QFileDialog::getSaveFileName(this, tr("保存图片"),QDir::currentPath(), tr("Images (*.png *.bmp *.jpg)"));if (filename.isNull()) return ;if (QFileInfo(filename).suffix().isEmpty()) //若后缀为空自动添加png后缀 filename.append(".png");