qgraphicsview

Qt: Overlapping semitransparent QgraphicsItem

孤者浪人 提交于 2019-12-11 09:38:27
问题 I've been working with QGraphicsView for a while and I am facing a requisite that I am not sure if it can be fulfilled by using this framework. Putting it as simple as possible, I have 2 overlapping RectItem with a semitransparent QBrush (the same one for both). Is it possible to prevent the overlapping area from becoming more opaque? I just want the whole area to have the same color (this will occur only if both rects are fully opaque, but sometimes that is not the case) I know it might seem

Zoom functionality using Qt

烈酒焚心 提交于 2019-12-11 07:36:40
问题 Current implementation, zooms towards the center of View so items present in the top left corner or the current mouse pointer is not visible when we Zoom it. I want zoom functionality based on the current mouse pointer so items present on the current mouse pointer zoom towards the center of the view. Code for Zoom base don center of view area void csGuiView::wheelEvent(QWheelEvent *event) { if ((event->modifiers()&Qt::ControlModifier) == Qt::ControlModifier && event->angleDelta().x() == 0) {

QGraphicsItem paint delay

帅比萌擦擦* 提交于 2019-12-11 07:23:07
问题 What could be the possible reason for this? When i zoom in the QGraphicsView and move the QGraphicsItem, I get this weird result. It does update if I zoom or pan the View again or if I focus on other widgets. Im using PySide. And the painter function is this def paint(self, painter, option, widget): if self.isSelected(): brush = self.highlight_brush pen = self.highlight_pen else: brush = self.dormant_brush pen = self.dormant_pen painter.setBrush(brush) painter.setPen(pen) painter.drawRect(0,

Custom QGraphicsItems not compiling and gives “object is private” error

匆匆过客 提交于 2019-12-11 06:33:18
问题 I am trying to create a Custom QGraphicsItem button as shown by Fred here. The code which he posted can be found here. The problem is when I try and compile the code I get the following two errors: /usr/include/qt4/QtGui/qgraphicsitem.h ‘QGraphicsItem::QGraphicsItem(const QGraphicsItem&)’ is private /usr/include/qt4/QtCore/qobject.h ‘QObject::QObject(const QObject&)’ is private Here is the code snippet which essentially is the same as that in the sample above. The error is on the class

For QGraphicsScene using setZValue on a QGraphicsItem causes major slowdown

旧时模样 提交于 2019-12-11 05:21:56
问题 I'm using Qt (Mac, version 4.7) to rendering a rather large scene (map data from Open Street Maps) with QGraphicsView and QGraphicsScene. Everything works great until I try to set the Z value for the items in the scene. I've tried two separate approaches to do this. In one, I just do: QGraphicsPathItem *item = scene->addPath(path, pen); item->setZValue(z); and the other I create my own QGraphicsItem subclass, but get the exact same problem. The cause of the slow down appears to be on the Qt

QGraphicsScene does not have a function to remove QWidget

孤者浪人 提交于 2019-12-11 04:03:12
问题 QGraphicsScene has an addWidget(QWidget *) function, but no corresponding removeWidget(QWidget *) . It has only removeItem(QGraphicsItem *) . How do I remove a QWidget? 回答1: Here's a basic sample, see if it works for you. QGraphicsScene scene; QPushButton *button = new QPushButton; //Add item and obtain QGraphicsProxyWidget QGraphicsProxyWidget *proxy = scene.addWidget(button); //Remove item scene.removeItem(proxy); Just remember to delete any memory you allocate. Edit: After OP's comments,

Moving QGraphicsItem by mouse in a QGraphicsScene

谁都会走 提交于 2019-12-11 03:36:09
问题 I have a QGraphicsScene and its associated QGraphicsView . I let the user create some shapes in the form of derived QGraphicsItem s into that scene. I also want them to be movable by mouse. Clicking one or more items select them, and moving them around while the mouse button is pressed works. I inherited QGraphicsView to do this, and overrided mousePressedEvent , mouseReleasedEvent & mouseMoveEvent to achieve this. When the user clicks, I am basically testing if an item (accessed through

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

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