[英]PySide6 setPageMargins()
I tried setting qprinter margins in PySide6 it throws an error我尝试在 PySide6 中设置 qprinter 边距它会引发错误
PySide6.QtGui.QPagedPaintDevice.setPageMargins(): too many arguments PySide6.QtGui.QPagedPaintDevice.setPageMargins():参数太多
document = QtGui.QTextDocument()
p = QtPrintSupport.QPrinter()
p.setResolution(100)
p.setPageMargins(1, 6, 1, 1, QtPrintSupport.QPrinter().Millimeter)
document.setPageSize(QSizeF(p.pageRect().size()))
this works on PyQt5这适用于 PyQt5
It seems that PySide6 is more strict with enums and does not auto-convert like PyQt5 so the code should be:似乎 PySide6 对枚举更严格,并且不像 PyQt5 那样自动转换,所以代码应该是:
document = QtGui.QTextDocument()
p = QtPrintSupport.QPrinter()
p.setResolution(100)
p.setPageMargins(QtCore.QMargins(1, 6, 1, 1), QtGui.QPageLayout.Millimeter)
document.setPageSize(
QtCore.QSizeF(p.pageRect(QtPrintSupport.QPrinter.Millimeter).size())
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.