QTableWidget print problem
-
I created a print button for the QTableWidget where I display the db data, but after the dialog window that appears, I get an error. my code is as below :
def PrintPrinter(self): printer = QPrinter(QPrinter.HighResolution) dialog = QPrintDialog(printer, self) if dialog.exec_() == QPrintDialog.Accepted: self.ui.table_PrinterData.print_(printer)
if the result:
AttributeError: 'PySide2.QtWidgets.QTableWidget' object has no attribute 'print_'I need information on how to proceed
-
-
@JokerSob It seems that you are copying code without understanding it, I presume that in the original example QTextDocument was being used (or QTextEdit that has a QTextDocument) that does have the print_ method for it but that is the case of QWidget such as QTableWidget. Use
render()
method. -
@eyllanesc said in QTableWidget print problem:
It seems that you are copying code without understanding it, I presume that in the original example QTextDocument was being used (or QTextEdit that has a QTextDocument) that does have the print_ method for it but that is the case of QWidget such as QTableWidget. Use render() method.
yes, I looked here, but I couldn't find it, so I looked at external source examples, I knew it would not be suitable, but I wanted to do a trial and error method, the result did not surprise me either. meanwhile .render() worked but tablewidget is taking screenshot I guess I need to do more research and improve this code to make it work as I want.
by the way thank you