The unit for QTextDocument is point (pt).
const qreal PT_MM = 25.4/72.0;
document.setDocumentMargin(20.0/PT_MM); // sets margin to 20mm
const qreal PT_MM = 25.4/72.0;
document.setDocumentMargin(20.0/PT_MM); // sets margin to 20mm
To copy to clipboard, switch view to plain text mode
It also works with html images:
document.setHtml("<img src=\"anyimg.jpg\" width = 200 />); // creates an image 200pt = 200*PT_MM millimeters wide
document.setHtml("<img src=\"anyimg.jpg\" width = 200 />); // creates an image 200pt = 200*PT_MM millimeters wide
To copy to clipboard, switch view to plain text mode
To set a PageSize use:
document.setPageSize(size);
QSizeF size = printer.paperSize(QPrinter::Point);
document.setPageSize(size);
To copy to clipboard, switch view to plain text mode
Bookmarks