qgraphicsscene

QGraphicsPixmapItem not selectable

試著忘記壹切 提交于 2019-12-11 02:21:35
问题 I want my QGraphicsPixmapItem become selectable (i.e. clickable in more general way) on QGraphicScene but it doesn't. I'm actually modifying Qt 's Diagram Scene sample, where QGraphicsItem 's subclass is used and is selectable. I appreciate your help. cpp code (partial): #include <iostream> #include <QtGui> #include "overlayPixmapItem.h" OverlayPixmapItem::OverlayPixmapItem(DiagramType diagramType, QMenu *contextMenu, QPixmap img, QGraphicsItem *parent, QGraphicsScene *scene) :

QGraphicsView doesn't resize after pixmap scale, while pixmap not centered any more

大城市里の小女人 提交于 2019-12-11 01:57:58
问题 I have created a QGraphicsView and inside it a QGraphicsScene. I load a pixmap in the QGraphicsScene. Actually it's an inherited QGraphicsScene which implements a wheelEvent in order to make the zoom in/out function. Zoom function scales the pixmap by 10% up or down depending on the wheel's rotation. The scaling works fine, however the QGraphicsView size or QGraphicsScene size gets the value of maximum size of the rotation that was tried and not center any more. For example, If I scale it up

PyQt/PySide How to access/move QGraphicsItem after having added it to QGraphicsScene

天大地大妈咪最大 提交于 2019-12-11 01:42:19
问题 This might be a very uninformed question. I've been trying to figure out QGraphics* , and have run into a problem when trying to move an item (a pixmap) relative to or inside of the QGraphicsView . class MainWindow(QMainWindow,myProgram.Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.scene = QGraphicsScene() self.graphicsView.setScene(self.scene) pic = QPixmap('myPic.png') self.scene.addPixmap(pic) print(self.scene.items()) This is the relevant part of the

QMouseEvent, received unexpected type

时间秒杀一切 提交于 2019-12-11 00:13:38
问题 I'm trying to link a mouse press event to displaying the coordinates of the mouse when clicked in a QLabel . A few problems... when I was passing a generic QWidget.mousePressEvent , the coordinates would only display the first time clicked. When I tried to make the mouse event specific to a GraphicsScene(self.p1) , I get the following error: Traceback (most recent call last): File "C:\Users\Tory\Desktop\DIDSONGUIDONOTCHANGE.py", line 59, in mousePressEvent self.p1.mousePressEvent(event)

Render QGraphicsScene according to zoom level

最后都变了- 提交于 2019-12-10 22:14:13
问题 Is there a (quick?) way to render only a subset of GraphicsScene items according to View zoom level? I'm having a big scene with many grid lines and i want to hide/show some of them, when the zoom changes to avoid the 'grid completely fills the scene'-effect. Grid lines are drawn using addLine method of GraphicsScene. P.S. Maybe, the easiest way is to draw grid somewhere else (on view or smth like that), because logically they aren't a part of my scene, they are only guide-lines? But i don't

In ScrollHandDrag mode of QGraphicsView, How to stop movement of QGraphicsItems on scene?

无人久伴 提交于 2019-12-10 12:58:53
问题 I have multiple QGraphicsItem s in scene spread across different parts of scene. In application there are different modes in one of mode user can scroll the scene (palm drag mode). To achieve scrolling over scene I set dragMode of QGraphicsView to ScrollHandDrag . But the problem is when user try to scroll over scene by dragging ( MousePress and MouseMove ) on any of QGraphicsItem instead of scrolling scene it moves QGraphicsItem . How can I stop movement of QGraphicsItem and scroll the scene

How to erase a QGraphicsItem from QGraphicsView using QPushButton

旧城冷巷雨未停 提交于 2019-12-10 11:58:49
问题 I am building a major user interface but I am stuck on a problem and in order to shrink the problem I build a small working example that carries exactly the problem. After the user creates a new .db file using the icon and saving for example to Desktop it is possible to load images(only in .png format for now) in the QGraphicsView and cliking on the checkbox to enable from Right: Drag to Right:Select it is possible to draw boxes on the image. With a right click inside the drawn box we can

Interactively editing an existing rectangle on a QPixmap?

十年热恋 提交于 2019-12-09 08:04:18
I'm trying to creat a Dicom GUI Toolkit where the user selects some dicom images and the image of first dicom image from the selected ones will be shown. Then the user clicks on the image and the image pops out with bigger image window. In this shown bigger image, the image will consist of a red colored rectangle that contains necessary regions of the Dicom image while the unnecessary region is outside the rectangle. The user should then have the option to change the rectangle by mouse. Until now, I have been able to show the big dicom image with the rectangle in it using QLabel which is by

Selecting several items and then taking distance between them

只愿长相守 提交于 2019-12-08 10:37:49
问题 I am currently having an issue with finding the distance between two items in a QGraphicsScene. I have the distance formula already down but the issue is that when I select two points or items in the graphicsScene it says they are at the same point and since they are at the same point the distance always comes out zero. To select multiple items I use ctrl + click to get two points selected at once and I know the two points are at different areas in the scene. Here is the code: import sys from

QT QGraphicsScene Drawing Arc

荒凉一梦 提交于 2019-12-08 07:02:33
问题 I have a question about drawing specific arc on a scene. I have this information about arc: Starting Koordinates, Start Angle, End Angle , Radius. But I can't use them efficently with QPainter . Actually I tried QPainterPath to use shape to show on QGraphicsScene with addPath("") but I can't use function properly. My questions are about how to use this infortmation to draw arc and how to show it on my graphic scene. 回答1: You can use a QGraphicsEllipseItem to add ellipses, circles, and