qgraphicsscene

Interactively editing an existing rectangle on a QPixmap?

[亡魂溺海] 提交于 2019-12-08 05:00:47
问题 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

how to use mouse move event for QGraphicsScene?

纵然是瞬间 提交于 2019-12-08 04:18:32
问题 hey want to drag this bezier curve when mouse button is pressed and moved.. I did this: void MainWindow::mouseMoveEvent(QMouseEvent *e) { qDebug()<<"in mouse move - outside if"; if((e->buttons() & Qt::RightButton) && isStart && enableDrag) { qDebug()<<"mouse dragging happening"; xc2=e->pos().x(); yc2=e->pos().y(); drawDragBezier(xc2,yc2); } } this starts dragging when i press right button and start moving mouse in whole main window..but I want to start dragging only when I press mouse button

PyQt: Mouse events in QGraphicsView

社会主义新天地 提交于 2019-12-07 21:37:23
问题 I would like to write a simple program in Python with PyQt. I have a QGraphicsScene and I would like to do the following: There are 2 options using two RadioButtons: For generating points. This way if someone clicks on the scene an ellipse will appear. For selecting points. This way if someone clicks on a point the selected point will be returned. I'm kinda new at PyQt and also at GUI programming. My main problem is that I don't really understand how mouse events work in Qt. If someone was so

Subclassing QGraphicsView and setting drawBackground

故事扮演 提交于 2019-12-07 09:57:29
问题 I'm trying to make a function similar to impoly (from matlab) in Qt. Right now, I have a subclass of QGraphicsView and have set the virtual function "drawBackground" as: void roiwindow::drawBackground(QPainter *painter, const QRectF &rect) { painter->save(); painter->drawImage(rect, *refimage); painter->restore(); } This works great and is basically exactly what I want as far as the background layer. Now, I'm trying to add circles that will eventually act as nodes for the polygon. I did this

How to enable dragging in QGraphicsScene?

你离开我真会死。 提交于 2019-12-07 07:49:26
问题 I'm trying to put two pictures in the QGraphicsScene . One is fixed and the other one is movable. But I succeed only in putting those pictures in the QGraphicsScene , I can't move them. How can I achieve this? 回答1: You have to make sure the item is movable. Have a look at QGraphicsItem::setFlag. You'll have to do something like this : myImageItem->setFlag(QGraphicsItem::ItemIsMovable, true); 来源: https://stackoverflow.com/questions/3062465/how-to-enable-dragging-in-qgraphicsscene

pyqtgraph: how to drag a a plot item

…衆ロ難τιáo~ 提交于 2019-12-07 01:58:31
Currently trying to plot a scatter plot in pyqtgraph and trying to drag the plot items but unable to find the approach. Already looked at GraphicsScene sigMouseClicked, sigMouseMoved events. Any suggestions welcome. Let me know in case any further details are required from my side. Sample code which I am using: import pyqtgraph as pg import numpy as np w = pg.GraphicsWindow() w.show() x = [2,4,5,6,8]; y = [2,4,6,8,10]; pl = pg.PlotItem() pl.plot(x, y, symbol='o') w.addItem(pl) Have a look at pyqtgraph/examples/CustomGraphItem.py. The approach there is to create a GraphItem subclass that

Save/Load items from a QGraphicsScene

喜欢而已 提交于 2019-12-06 11:24:58
问题 I want to save all items in a QGraphicsScene to a file. When I load the file, I should be able to use them as QGraphicsItems(as before). I keep my items in a QList like QList of QGraphicsItems that i called mItemsOnScreen. I should be able to get back that list when i load the file.How can I save those items to a file on disk. What kind of a file format should i use? And of course how will i read that file back?Please Some Help...And Thank's in advance. I already do this but it save image

PyQt: Moving multiple items with different ItemIgnoresTransformations flags

只谈情不闲聊 提交于 2019-12-06 11:13:04
Sometimes selected items do not move together. This happens in an application with two types of items: "regular items" "handles" with ItemIgnoresTransformations flag (they must keep the same size upon zooming) When they are selected together, and moved by mouse, they are expected to be translated by the same amount (they should move as a whole). It works fine when only "regular items" or only "handles" are moved, but not when both types are selected. Here is a minimal example displaying the problem. It can also be found on sourceforge , together with an enhanced version displaying also some

QGraphicsScene scaled weirdly in QGraphicsView

对着背影说爱祢 提交于 2019-12-06 06:00:53
问题 I'm messing around with QGraphicsView and QGraphicsScene to create a Tic Tac Toe clone. I add some QGraphicsLineItem s to my scene and override the resizeEvent method of the Widget that contains the view, so that when the window is resized, the view and its contents are scaled appropriately. This works fine, except for the first time that I run the program: Once I resize the window by any amount, the scene is scaled correctly: Here's the code: main.cpp: #include <QtGui> #include "TestApp.h"

QGraphicsScene is missing a particular item update

时间秒杀一切 提交于 2019-12-06 05:43:43
问题 I've got an application where you can watch replays for a given 2D game : Basically, a vehicle is moving on a map. The view is centered on vehicle so the map is scrolling as replay is playing, something Micro Machines -like (it's just to give an idea, the actual game is not Micro Machines ). (source: randomracket.com) In my scene, the map is static while the vehicle is moving around. The view is scrolling for each frame of the replay, so that vehicle is centered. For performance reason, the