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. Printing content of QTextEdit

Printing content of QTextEdit

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 805 Views
  • 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.
  • L Offline
    L Offline
    LT-K101
    wrote on last edited by
    #1

    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)
    
    jsulmJ 1 Reply Last reply
    0
    • L LT-K101

      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)
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @LT-K101 I don't understand: do you want to print the content of text edit or the two labels?
      If you want to print the text edit then why not simply:

      def handlePaintRequest(self, printer):
              self.textEdit.print_(printer)
      

      ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • jsulmJ jsulm

        @LT-K101 I don't understand: do you want to print the content of text edit or the two labels?
        If you want to print the text edit then why not simply:

        def handlePaintRequest(self, printer):
                self.textEdit.print_(printer)
        

        ?

        L Offline
        L Offline
        LT-K101
        wrote on last edited by
        #3

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

        jsulmJ 1 Reply Last reply
        0
        • L LT-K101

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @LT-K101 You can print text and imeges and also widgets, see https://doc.qt.io/qt-5/qtprintsupport-index.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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