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. How to custom page size for printing using QPrinter in Pyside6
Qt 6.11 is out! See what's new in the release blog

How to custom page size for printing using QPrinter in Pyside6

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 1.3k 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.
  • K Offline
    K Offline
    kumar80
    wrote on last edited by
    #1

    I need to print bill as part of my app. The bill is of dimensions of width 10 inch and heigh 6 inch. I need to print on this type of paper. This app will run on linux. It will be printed using a dotmatrix printer.

    1. how do I set custom page size
    2. I need to set a dpi of 127x60 dpi. How to set resolution SetResolution method takes only one integer.

    When I run the below script it just stuck and nothing happens. It is stuck at Previewer windows Pleast wait.

    @Slot()
        def printPreview(self):
            if not self.m_page:
                return
            if self.m_inPrintPreview:
                return
            self.m_inPrintPreview = True
            printer = QPrinter()
            size=QSize(10,6)
            
            printer.setPageSize(size)
            printer.setResolution(8640)
            printer.setPrinterName("kamtest")
    
            preview = QPrintPreviewDialog(
                printer, QWebEngineView.forPage(self.m_page))
            preview.paintRequested.connect(self.printDocument)
            preview.exec()
            self.m_inPrintPreview = False
    
    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