Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QTableWidget print problem
Forum Updated to NodeBB v4.3 + New Features

QTableWidget print problem

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 3 Posters 723 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JokerSob
    wrote on last edited by
    #1

    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

    eyllanescE 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      See here in the module introduction page.

      You do not "print" widgets, you render them.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J JokerSob

        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

        eyllanescE Offline
        eyllanescE Offline
        eyllanesc
        wrote on last edited by
        #3

        @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.

        If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JokerSob
          wrote on last edited by JokerSob
          #4

          @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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved