QImage img(ui->widget->size, QImage::Format_RGB32); QPainter painter(&img); ui->widget->render(&painter); fileName = QString("%1/%2") .arg(QDesktopServices::storageLocation(QDesktopServices::TempLocation)) .arg("fichierTemporaire.jpg"); img.save(fileName);