Printing content of QTextEdit
Moved
Unsolved
Qt for Python
-
I have two labels one display an image and the other display a text. I want to preview or print the contents of the TextEdit but I get a blank page when I preview or print. Please any help on how to insert these two label in the third method below. Thanks in advance.
def handlePrint(self): dialog = QtPrintSupport.QPrintDialog() if dialog.exec_() == QtWidgets.QDialog.Accepted: self.handlePaintRequest(dialog.printer()) def handlePreview(self): dialog = QtPrintSupport.QPrintPreviewDialog() dialog.paintRequested.connect(self.handlePaintRequest) dialog.exec_() def handlePaintRequest(self, printer): document = QtGui.QTextDocument() document.print_(printer)
-
-
@jsulm Thanks for your reply. I was thinking if it possible to pass text from LineEdit and an image onto TextEdit and use the PrintPreviewDialog method to preview and print. I stand to be corrected if there is a better way to print values from a LineEdit and a label.
-
@LT-K101 You can print text and imeges and also widgets, see https://doc.qt.io/qt-5/qtprintsupport-index.html