qgraphicsview

QGraphicsView and eventFilter

有些话、适合烂在心里 提交于 2021-02-17 19:19:07
问题 This has been bugging me for more than two days now, so i thought i should ask. I am using Qt 4.5.3 (compiled with VC2008) on Win7. I have MyGraphicsView (inherits QGraphicsView) and MyFilter (inherits QObject) classes. When i install the MyFilter object as an event filter to MyGraphicsView, Mouse events are delivered to MyFilter after they are delivered to MyGraphicsView whereas Key events are delivered to MyFilter before they are delivered to MyGraphicsView. In the second case, i install

Making QGraphicsScene bigger when a graphic item is placed against its border

▼魔方 西西 提交于 2021-02-08 05:19:22
问题 I've made a QGraphicsScene with a mouseClickEvent that lets the user create blue squares inside of it. But I want to make the scene grow when an item is placed against its border so that the user never runs out of space on the graphics scene. What's the best way to make a graphics scene bigger in this case? 回答1: I suggest doing something like the following: Get the bounding rect of all items in the scene using QGraphicsScene::itemsBoundingRect() . Add some padding around that rect to make

Making QGraphicsScene bigger when a graphic item is placed against its border

折月煮酒 提交于 2021-02-08 05:17:48
问题 I've made a QGraphicsScene with a mouseClickEvent that lets the user create blue squares inside of it. But I want to make the scene grow when an item is placed against its border so that the user never runs out of space on the graphics scene. What's the best way to make a graphics scene bigger in this case? 回答1: I suggest doing something like the following: Get the bounding rect of all items in the scene using QGraphicsScene::itemsBoundingRect() . Add some padding around that rect to make

Making QGraphicsScene bigger when a graphic item is placed against its border

喜你入骨 提交于 2021-02-08 05:17:47
问题 I've made a QGraphicsScene with a mouseClickEvent that lets the user create blue squares inside of it. But I want to make the scene grow when an item is placed against its border so that the user never runs out of space on the graphics scene. What's the best way to make a graphics scene bigger in this case? 回答1: I suggest doing something like the following: Get the bounding rect of all items in the scene using QGraphicsScene::itemsBoundingRect() . Add some padding around that rect to make

How to get cursor click position in QGraphicsItem coordinate system?

淺唱寂寞╮ 提交于 2021-02-07 20:57:51
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

How to get cursor click position in QGraphicsItem coordinate system?

天大地大妈咪最大 提交于 2021-02-07 20:56:50
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

How to get cursor click position in QGraphicsItem coordinate system?

99封情书 提交于 2021-02-07 20:55:29
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

Unable to fully remove border of PyQt QGraphicsView

喜你入骨 提交于 2021-02-07 19:11:43
问题 I have tried calling self.setStyleSheet("background: transparent; border: transparent;") on a QGraphicsView, but it still leaves a 1 pixel border on the top edge. I have also tried replacing border: transparent; with border-style: none; , but it didn't work either. Here is a screenshot of the problem: What command will fully remove the border from the QGraphicsView? 回答1: You can use one of the following css rule: graphicsView.setStyleSheet("border-width: 0px; border-style: solid") or

PyQT User Editable Polygons

不想你离开。 提交于 2021-02-07 10:19:54
问题 I am using QPainter and QPolygon classes to paint polygons over an image. I need the user to be able to edit this polygons by dragging the points in them. The QPolygon and QPainter classes don't have any signals, so I can't trigger the event through them. I have realized that if I keep on using this approach, then the image would have to be rendered each time a point is moved would probably look really bad and not smooth at all. Anybody know how I could put these points on top of the image

PyQT User Editable Polygons

妖精的绣舞 提交于 2021-02-07 10:18:07
问题 I am using QPainter and QPolygon classes to paint polygons over an image. I need the user to be able to edit this polygons by dragging the points in them. The QPolygon and QPainter classes don't have any signals, so I can't trigger the event through them. I have realized that if I keep on using this approach, then the image would have to be rendered each time a point is moved would probably look really bad and not smooth at all. Anybody know how I could put these points on top of the image