Qt弹出对话框按指定路径保存图片

void balser_c::SavePictureTriggered(QPixmap img)
{

QImage img2 = img.toImage();

QString filename = QFileDialog::getSaveFileName(this,
	tr("Save Image"),
	"",
	tr("*.bmp;; *.png;; *.jpg;; *.tif;; *.GIF")); //选择路径
if (filename.isEmpty())
{
	return;
}
else
{
	if (!(img2.save(filename))) //保存图像
	{

		QMessageBox::information(this,
			tr("Failed to save the image"),
			tr("Failed to save the image!"));
		return;
	}
	ui.statusBar->showMessage("图片保存成功");
}

}

你可能感兴趣的:(Qt)