QString 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");