Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Need to implement Print Dialog Box

Need to implement Print Dialog Box

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.2k 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.
  • P Offline
    P Offline
    Piyush
    wrote on 7 Feb 2018, 06:42 last edited by
    #1

    Hi,
    I need to implement a Print Dialog box which on clicking a button will pop up and ask for printer configuration. How can I do it in Python?

    J J 2 Replies Last reply 7 Feb 2018, 07:08
    0
    • P Piyush
      7 Feb 2018, 06:42

      Hi,
      I need to implement a Print Dialog box which on clicking a button will pop up and ask for printer configuration. How can I do it in Python?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 Feb 2018, 07:08 last edited by
      #2

      @Piyush Did you check http://doc.qt.io/qt-5/qprintdialog.html?

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

      1 Reply Last reply
      0
      • P Piyush
        7 Feb 2018, 06:42

        Hi,
        I need to implement a Print Dialog box which on clicking a button will pop up and ask for printer configuration. How can I do it in Python?

        J Offline
        J Offline
        JonB
        wrote on 7 Feb 2018, 10:40 last edited by
        #3

        @Piyush
        From PyQt:

        from PyQt5.QtPrintSupport import QPrintDialog
        
        P 1 Reply Last reply 7 Feb 2018, 10:47
        0
        • J JonB
          7 Feb 2018, 10:40

          @Piyush
          From PyQt:

          from PyQt5.QtPrintSupport import QPrintDialog
          
          P Offline
          P Offline
          Piyush
          wrote on 7 Feb 2018, 10:47 last edited by
          #4

          @JonB Hi,

          I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.

          def print_widget(self):
              printer = QtPrintSupport.QPrinter()                    
              setupdialog = QPrintDialog(printer,self)
              if setupdialog.exec_() == QPrintDialog.Accepted:
                  painter = QtGui.QPainter(self)
                  painter.begin(printer)
                  point = QtCore.QPoint(0,0)
                  screen = self.grab()
                  self.pixmap = QtGui.QPixmap(screen)
                  scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation)
                  point.setX(0)
                  point.setY(0)
                  painter.drawPixmap(point, scaledPix)
                  painter.end()
          
          J J M 3 Replies Last reply 7 Feb 2018, 10:53
          0
          • P Piyush
            7 Feb 2018, 10:47

            @JonB Hi,

            I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.

            def print_widget(self):
                printer = QtPrintSupport.QPrinter()                    
                setupdialog = QPrintDialog(printer,self)
                if setupdialog.exec_() == QPrintDialog.Accepted:
                    painter = QtGui.QPainter(self)
                    painter.begin(printer)
                    point = QtCore.QPoint(0,0)
                    screen = self.grab()
                    self.pixmap = QtGui.QPixmap(screen)
                    scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation)
                    point.setX(0)
                    point.setY(0)
                    painter.drawPixmap(point, scaledPix)
                    painter.end()
            
            J Offline
            J Offline
            JonB
            wrote on 7 Feb 2018, 10:53 last edited by
            #5

            @Piyush
            Sorry I don't know. But this question has nothing to do with the QPrintDialog you ask about in the title, it's to do with drawing to a QPrinter.

            1 Reply Last reply
            0
            • P Piyush
              7 Feb 2018, 10:47

              @JonB Hi,

              I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.

              def print_widget(self):
                  printer = QtPrintSupport.QPrinter()                    
                  setupdialog = QPrintDialog(printer,self)
                  if setupdialog.exec_() == QPrintDialog.Accepted:
                      painter = QtGui.QPainter(self)
                      painter.begin(printer)
                      point = QtCore.QPoint(0,0)
                      screen = self.grab()
                      self.pixmap = QtGui.QPixmap(screen)
                      scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation)
                      point.setX(0)
                      point.setY(0)
                      painter.drawPixmap(point, scaledPix)
                      painter.end()
              
              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 7 Feb 2018, 11:32 last edited by
              #6

              @Piyush said in Need to implement Print Dialog Box:

              self.pixmap.scaled

              Did you try other sizes for scaled()?

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

              1 Reply Last reply
              2
              • P Piyush
                7 Feb 2018, 10:47

                @JonB Hi,

                I am using the following code. But I am getting print in small size i.e. the whole widget is coming in smaller area of the page.

                def print_widget(self):
                    printer = QtPrintSupport.QPrinter()                    
                    setupdialog = QPrintDialog(printer,self)
                    if setupdialog.exec_() == QPrintDialog.Accepted:
                        painter = QtGui.QPainter(self)
                        painter.begin(printer)
                        point = QtCore.QPoint(0,0)
                        screen = self.grab()
                        self.pixmap = QtGui.QPixmap(screen)
                        scaledPix = self.pixmap.scaled(1100,950,Qt.KeepAspectRatio,transformMode = Qt.SmoothTransformation)
                        point.setX(0)
                        point.setY(0)
                        painter.drawPixmap(point, scaledPix)
                        painter.end()
                
                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 7 Feb 2018, 12:15 last edited by
                #7

                @Piyush
                Hi
                Its the same as here
                https://forum.qt.io/topic/87293/how-to-print-the-current-tab-on-pressing-a-push-button

                Screen is normally maybe 1920x1080 pixels
                where as printer might
                be 9000 x 9000 pixels

                So if you have an image of 200x200
                on screen it look ok big.

                But if you print it. then 200 pixels out of 9000 looks like the size
                of a stamp.

                https://en.wikipedia.org/wiki/Dots_per_inch

                1 Reply Last reply
                1

                1/7

                7 Feb 2018, 06:42

                • Login

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