How to print/screenshot a tabwidget to an image file (.jpg/.png) in high resolution?
Solved
General and Desktop
-
Hi,
I am working on a piece of code wherein I have to print the tabwidget to an image file (.png/.jpg) file. The file is being created by the following code but i cannot view it.
Code:
``` printer.PrinterMode(QtPrintSupport.QPrinter.HighResolution) printer.setOrientation(QtPrintSupport.QPrinter.Landscape) printer.setPaperSize(QtCore.QSizeF(297, 420), QtPrintSupport.QPrinter.Millimeter) temp_pdf = "abc.png" printer.setOutputFileName(temp_pdf) painter = QtGui.QPainter(printer) painter.drawPixmap(0, 10, self.ui.tabWidget.grab()) painter.end()
-
Do you want to send the picture to a printer or why do you use QPrinter instead QPixmap::save()?
-
@Piyush
hi
There is
http://doc.qt.io/qt-5/qwidget.html#render
which you can use to directly make tabwidget draw to pixmap.