QPrinter printer(QPrinter::HighResolution); QRect pageRect = printer.pageRect();
QPrinter printer(QPrinter::HighResolution); QRect pageRect = printer.pageRect(); printer.setPageMargins(pageRect.left(), pageRect.top(), pageRect.width() - pageRect.right(), pageRect.height() - pageRect.bottom(), QPrinter::DevicePixel);In this example, a QPrinter object is created with the HighResolution page size option. The pageRect() function is called on the printer object to get the dimensions of the printable area on the current page. The left, top, right, and bottom margins of the printer object are set to match the printable area on the page. The last argument, QPrinter::DevicePixel, specifies that the margin units should be in device pixels. Package library: Qt