qgraphicsview

Tiling with QGraphicsScene and QGraphicsView

落花浮王杯 提交于 2019-12-04 10:57:03
问题 I'm creating a image visualizer that open large images(2gb+) in Qt. I'm doing this by breaking the large image into several tiles of 512X512. I then load a QGraphicsScene of the original image size and use addPixmap to add each tile onto the QGraphic Scene. So ultimately it looks like a huge image to the end user when in fact it is a continuous array of smaller images stuck together on the scene.First of is this a good approach? Trying to load all the tiles onto the scene takes up a lot of

How to show pixel position and color from a QGraphicsPixmapItem

百般思念 提交于 2019-12-04 10:36:27
I'm developing a custom widget with QGraphicsScene/View and I have no prior experience with it. The custom widget is an image viewer that needs to track mouse movement and send signal(s) to it's parent dialog / window. The signal(s) will be the position of the pixel under the mouse cursor and it's color (in RGB). A status bar will use that information. I use a QGraphicsPixmapItem to display the image I load from a file in the scene. Thanks. First of all you have to implement the mouseMoveEvent in your custom item. In this function you can easily get the mouse position calling the pos function.

Best way to create a long line (or cross line) cursor in Qt GraphicsView

▼魔方 西西 提交于 2019-12-04 10:29:44
The easy way to create the long cross line cursor (as long as viewport) is create a cross line graphicsItem , when mouse moved, set the item's pos property. But this way will be very slow when the scene is complex, because it should update the whole viewport to update the cursor's pos . The another easy way is setCursor(QCursor(..)) ,use a QPixmap to define the long cross line, this way will very fast , but the cursor will exceed the viewport rect. Is there another way to show a long cross line cursor fastly? Thanks very much! If I understand correctly, you want to draw an horizontal line and

restrict movable area of qgraphicsitem

主宰稳场 提交于 2019-12-04 07:26:52
Is there a way to restrict the area where a QGraphicsItem like QRect can be moved when setFlag(ItemIsMovable) is set? I'm new to pyqt and trying to find a way to move an item with the mouse, and the restrict it to only vertically/horizontally. If you want to keep a limited area you can reimplement the ItemChanged() Declare: #ifndef GRAPHIC_H #define GRAPHIC_H #include <QGraphicsRectItem> class Graphic : public QGraphicsRectItem { public: Graphic(const QRectF & rect, QGraphicsItem * parent = 0); protected: virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value ); };

Pyside2 How can i move box?

为君一笑 提交于 2019-12-04 04:15:42
问题 I want to move my SimpleItem object if I move mouse pressing left button. I have successed getting the position of mouse cursor if I press the object. but I have no idea how to move the item to that position. Could you help me? import sys from PySide2 import QtGui, QtWidgets, QtCore class SimpleItem(QtWidgets.QGraphicsItem): def __init__(self): QtWidgets.QGraphicsItem.__init__(self) self.location = 1.0 def boundingRect(self): penWidth = 1.0 return QtCore.QRectF(-10 - penWidth / 2, -10 -

Tracking mouse move in QGraphicsScene class

杀马特。学长 韩版系。学妹 提交于 2019-12-03 22:31:55
I subclassed QGraphicsScene and added method mouseMoveEvent to handle mouse move event. I created a ruler on top of GraphicsView and have the ruler tracking mouse movement. In the QGraphicsScene::mousemoveEvent I calls mouseMoveEvent of the ruler widget explcitely. The purpose is to have the ruler knows that the current mouse position. Now it seems that QGraphicsScene::mousemoveEvent is not called when I move the mouse. However, I can get it to work if I press the left mouse button and move it while holding the button. This is not what I'd like to see; I'd like this method is called whenever I

How to pan beyond the scrollbar range in a QGraphicsview?

坚强是说给别人听的谎言 提交于 2019-12-03 14:53:00
问题 I am building a node graph in a QGraphicsView and I am currently implementing panning. I used the following question "how to pan images in QGraphicsView" to start but the panning is limited by the scrollbar range. I also tried the translate method but it gives the same result. The view is limited to a certain rectangle. I would like to pan without limits, the graph can becomes quite large and it is useful to be able to work in different area of the scene (one graph here, another graph over

How to select multiple items without pressing Ctrl key within QGraphicsScene?

守給你的承諾、 提交于 2019-12-03 13:53:03
问题 In Qt's QGraphicsScene , if I wanna one item, just click it, and click another selectable item will make the selected item to be unselected. If I want to select multiple items, I'd use Ctrl-key. But this maybe not convenient for some cases, then how to select multiple items without pressing Ctrl-key within QGraphicsScene ? 回答1: You want to change the default behavior of QGraphicsScene , so you have to create your own scene class, inheriting QGraphicsScene . In your class, you'll have to

Getting started with a Tile-based game in Qt using QGraphicsScene and QGraphicsView

雨燕双飞 提交于 2019-12-03 13:11:54
I'm going to start programming a 2D tile-based game in Qt and read about the QGraphicsScene and QGraphicsView classes which are intended for displaying and handling lots of 2D objects. My question is that will it be feasible to create a world with lots of tiles using QGraphicsScene? Can I add the whole world at once tile-by-tile or should I try to implement something to restrict the area a bit? I've read that QGraphicsScene can handle "thousands of items" but a 2D tile map can easily get really, really big (200x200 tiles? not that many, but that's already 40,000 objects which is a lot). The

How to set QGraphicsScene/View to a specific coordinate system

南楼画角 提交于 2019-12-03 11:07:02
问题 I want to draw polygons in a QGraphicsScene but where the polygons has latitude/longitude positions. In a equirectangular projection the coordinates goes from: ^ 90 | | -180----------------------------------->180 | | -90 How can I set the QGraphicsScene / QGraphicsView to such projection? Many thanks, Carlos. 回答1: Use QGraphicsScene::setSceneRect() like so: scene->setSceneRect(-180, -90, 360, 180); If you're concerned about the vertical axis being incorrectly flipped, you have a few options