Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. void MainWindow::on_actionSave_triggered()
  2. {
  3. // Opens a saving browser for the user to choose where he wants to save the file and its name.
  4. QString fileName = QFileDialog::getSaveFileName(this, tr("Save Picture"), "", tr("Files (*.*)"));
  5. QPixmap picture = *ui->label->pixmap();
  6.  
  7. // Checks if the user added an extension to the picture, if he didn't, the default saving is .jpg.
  8. if(!(fileName.contains(".png") || fileName.contains(".jpg") || fileName.contains(".bmp"))) fileName.append(".jpg");
  9. picture.save(fileName);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement