Here is the easiest way to save the widget as an image while working on Qt 5:
QString file = QFileDialog::getSaveFileName(this, "Save as...", "name", "PNG (*.png);; BMP (*.bmp);;TIFF (*.tiff *.tif);; JPEG (*.jpg *.jpeg)"); ui->myWidget->grab().save(file);
Danio source share