eric6/E5Graphics/E5GraphicsView.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
45 super(E5GraphicsView, self).__init__(scene, parent) 45 super(E5GraphicsView, self).__init__(scene, parent)
46 self.setObjectName("E5GraphicsView") 46 self.setObjectName("E5GraphicsView")
47 47
48 self.__initialSceneSize = self.scene().sceneRect().size() 48 self.__initialSceneSize = self.scene().sceneRect().size()
49 self.setBackgroundBrush(QBrush(self.getBackgroundColor())) 49 self.setBackgroundBrush(QBrush(self.getBackgroundColor()))
50 self.setRenderHint(QPainter.Antialiasing, True) 50 self.setRenderHint(QPainter.RenderHint.Antialiasing, True)
51 self.setDragMode(QGraphicsView.RubberBandDrag) 51 self.setDragMode(QGraphicsView.DragMode.RubberBandDrag)
52 self.setAlignment(Qt.Alignment(Qt.AlignLeft | Qt.AlignTop)) 52 self.setAlignment(Qt.Alignment(
53 self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 53 Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop))
54 self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) 54 self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
55 self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate) 55 self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
56 self.setViewportUpdateMode(
57 QGraphicsView.ViewportUpdateMode.SmartViewportUpdate)
56 58
57 self.setWhatsThis(self.tr( 59 self.setWhatsThis(self.tr(
58 "<b>Graphics View</b>\n" 60 "<b>Graphics View</b>\n"
59 "<p>This graphics view is used to show a diagram. \n" 61 "<p>This graphics view is used to show a diagram. \n"
60 "There are various actions available to manipulate the \n" 62 "There are various actions available to manipulate the \n"
303 paintDevice.setResolution(100) # 100 dpi 305 paintDevice.setResolution(100) # 100 dpi
304 paintDevice.setSize(QSize(int(rect.width()), int(rect.height()))) 306 paintDevice.setSize(QSize(int(rect.width()), int(rect.height())))
305 paintDevice.setViewBox(rect) 307 paintDevice.setViewBox(rect)
306 paintDevice.setFileName(filename) 308 paintDevice.setFileName(filename)
307 painter = QPainter(paintDevice) 309 painter = QPainter(paintDevice)
308 painter.setRenderHint(QPainter.Antialiasing, True) 310 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
309 self.scene().render(painter, QRectF(), rect) 311 self.scene().render(painter, QRectF(), rect)
310 312
311 # step 3: reselect the widgets 313 # step 3: reselect the widgets
312 if selectedItems: 314 if selectedItems:
313 for item in selectedItems: 315 for item in selectedItems:
418 painter.drawRect(marginX, marginY, width, height) 420 painter.drawRect(marginX, marginY, width, height)
419 painter.drawLine(marginX, marginY + height + 2, 421 painter.drawLine(marginX, marginY + height + 2,
420 marginX + width, marginY + height + 2) 422 marginX + width, marginY + height + 2)
421 painter.setFont(font) 423 painter.setFont(font)
422 painter.drawText(marginX, marginY + height + 4, width, 424 painter.drawText(marginX, marginY + height + 4, width,
423 fontHeight, Qt.AlignRight, s) 425 fontHeight, Qt.AlignmentFlag.AlignRight, s)
424 if not finishX or not finishY: 426 if not finishX or not finishY:
425 printer.newPage() 427 printer.newPage()
426 page += 1 428 page += 1
427 429
428 painter.end() 430 painter.end()

eric ide

mercurial