replace QDesktopWidget() with QGuiApplication.primaryScreen()
the "try, except" could be dropped if we drop Qt4 support. however, primaryScreen() may not be the right screen.
This commit is contained in:
parent
92016d3d5a
commit
1a6918a241
@ -45,7 +45,11 @@ class PrintExporter(Exporter):
|
||||
#res = printer.resolution()
|
||||
sr = self.getSourceRect()
|
||||
#res = sr.width() * .4 / (self.params['width'] * 100 / 2.54)
|
||||
res = QtGui.QDesktopWidget().physicalDpiX()
|
||||
try:
|
||||
res = QtGui.QDesktopWidget().physicalDpiX()
|
||||
except AttributeError:
|
||||
# This is available since Qt 5
|
||||
res = QtGui.QGuiApplication.primaryScreen().physicalDotsPerInchX()
|
||||
printer.setResolution(res)
|
||||
rect = printer.pageRect()
|
||||
center = rect.center()
|
||||
|
@ -195,7 +195,11 @@ def _generateItemSvg(item, nodes=None, root=None, options={}):
|
||||
buf = QtCore.QBuffer(arr)
|
||||
svg = QtSvg.QSvgGenerator()
|
||||
svg.setOutputDevice(buf)
|
||||
dpi = QtGui.QDesktopWidget().logicalDpiX()
|
||||
try:
|
||||
dpi = QtGui.QDesktopWidget().logicalDpiX()
|
||||
except AttributeError:
|
||||
# This is available since Qt 5
|
||||
dpi = QtGui.QGuiApplication.primaryScreen().logicalDotsPerInchX()
|
||||
svg.setResolution(dpi)
|
||||
|
||||
p = QtGui.QPainter()
|
||||
|
Loading…
Reference in New Issue
Block a user