qgraphicsview

Add ports to the QGraphicsPixmapItem object

纵然是瞬间 提交于 2019-12-01 02:13:59
I've created something like this. I have created a QGraphicsPixmapItem object that I can add to QGraphicsView. I want to add ports to these objects I created. And I want to make connections between these ports and the objects I have created. I don't know how to do it. can you help me ? my code class Part(QGraphicsPixmapItem): def __init__(self, name): super().__init__() self.name = name self.setFlags(self.ItemIsSelectable | self.ItemIsMovable | self.ItemIsFocusable) self.label = QLabel("Deneme") self.pixmap = QPixmap("image/" + name + ".png") self.setPixmap(self.pixmap) self.inputs = {} self

Painting background on QGraphicsView using drawBackground

泪湿孤枕 提交于 2019-12-01 00:19:41
I have a problem trying to paint and draw on QGraphicsView/Scene . I'm drawing a bunch of QLineF as background overriding QGraphicsView::drawBackGround`. However, when I try to change the background color nothing happens. Here is minimal example of what I'm doing: import sys import platform import ctypes from PySide import QtCore, QtGui from mygv import Ui_Dialog import sys class myView(QtGui.QDialog): def __init__(self, parent = None): QtGui.QDialog.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.ui.view.drawBackground = self.drawBackground self.ui.view.wheelEvent =

Add ports to the QGraphicsPixmapItem object

余生长醉 提交于 2019-11-30 20:28:41
问题 I've created something like this. I have created a QGraphicsPixmapItem object that I can add to QGraphicsView. I want to add ports to these objects I created. And I want to make connections between these ports and the objects I have created. I don't know how to do it. can you help me ? my code class Part(QGraphicsPixmapItem): def __init__(self, name): super().__init__() self.name = name self.setFlags(self.ItemIsSelectable | self.ItemIsMovable | self.ItemIsFocusable) self.label = QLabel(

Painting background on QGraphicsView using drawBackground

谁说我不能喝 提交于 2019-11-30 19:24:08
问题 I have a problem trying to paint and draw on QGraphicsView/Scene . I'm drawing a bunch of QLineF as background overriding QGraphicsView::drawBackGround`. However, when I try to change the background color nothing happens. Here is minimal example of what I'm doing: import sys import platform import ctypes from PySide import QtCore, QtGui from mygv import Ui_Dialog import sys class myView(QtGui.QDialog): def __init__(self, parent = None): QtGui.QDialog.__init__(self, parent) self.ui = Ui_Dialog

Playing image sequence in QGraphicsView (Mysterious Memory Leak)

こ雲淡風輕ζ 提交于 2019-11-30 16:08:01
问题 I'm trying to process an image sequence and make a video of the results using OpenCV and PyQt5. I've got some code that loops through a directory, reads in the images, and tries to display them on a QGraphicsView . def on_start(self): for f in self.image_list: img = cv2.imread(f) img = cv2qimage(img, False) self.scene.set_qimage(img) self.scene inherits from QGraphicsScene . def set_qimage(self, qimage): self.pixmap = QPixmap.fromImage(qimage) self.addPixmap(self.pixmap) The problem is

Maintaining relative child position after applying QGraphicsItem::ItemIgnoresTransformations

浪子不回头ぞ 提交于 2019-11-30 13:52:38
I have a QGraphicsTextItem parented to a QGraphicsItem. I want the QGraphicsTextItem to always reside directly above the QGraphicsItem, but I also want the text to remain the same size when the scale factor goes below 1, i.e. the text remains the size it is at a scale factor of 1 even when the parent graphics item is scaled smaller. I have found that setting the QGraphicsItem::ItemIgnoresTransformations flag to true when the scale factor is below 1 does the trick for retaining the size. But I can’t seem to find a way to get the position of the text to always remain above the QGraphicsItem. Is

pyqt add rectangle in Qgraphicsscene

一曲冷凌霜 提交于 2019-11-29 16:18:41
I have a scene like this class Scene(QtWidgets.QGraphicsScene): def __init__(self, parent=None): super(Scene, self).__init__(parent) def mousePressEvent(self, event): print('scene pressed') self.wid = MyRect(event.pos(), event.pos()) self.addItem(self.wid) self.wid.show() I would like class MyRect(QtWidgets.QGraphicsRectItem) with painter, mouse event and so on to be a draggable rectangle. all stuff in MyRect So then I could have many Rectangle to the scene and even after draw line between them and so on (kind of diagram app), but keeping objects related editable options in MyRect, MyLine , ..

Why I can't enlarge a widget added to QGraphicScene by QSizeGrip?

[亡魂溺海] 提交于 2019-11-29 16:17:43
I have added a widget to a graphic scene QGraphicScene through a QGraphicsProxyWidget. To move it I have set QGraphicsRectitem as its parent. The widget is resized with the use of a sizegrip. The first time I create an object I can enlarge it upto some dimension. The second time I can enlarge it less than the first one. The third time less than the second one and so on. It seems to me that it behaves randomly. Why is this happening? Here is the code: void GraphicsView::dropEvent(QDropEvent *event)// subclass of QGraphicsView { if(event->mimeData()->text() == "Dial") { auto *dial= new Dial; //

How to make a ruler on the border of a QGraphicsView

别说谁变了你拦得住时间么 提交于 2019-11-28 11:12:19
问题 I am working on a small .ui project and I am was trying to understand how to properly make a ruler on a QGraphicsView . So when the use sees the image it looks like the following: But if the user needs to zoom-in (or zoom-out) the ruler moves accordingly along with the value of the measurements: Thanks for shedding light on this issue and sor providing any potential example or point to the right direction. 回答1: Create a new class by subclassing QWidget to draw your ruler. Then, set a viewport

Why I can't enlarge a widget added to QGraphicScene by QSizeGrip?

寵の児 提交于 2019-11-28 09:33:35
问题 I have added a widget to a graphic scene QGraphicScene through a QGraphicsProxyWidget. To move it I have set QGraphicsRectitem as its parent. The widget is resized with the use of a sizegrip. The first time I create an object I can enlarge it upto some dimension. The second time I can enlarge it less than the first one. The third time less than the second one and so on. It seems to me that it behaves randomly. Why is this happening? Here is the code: void GraphicsView::dropEvent(QDropEvent