qgraphicsview

Qt: mouseMoveEvent and interfer with hoverEnterEvent of child object

Hi! I use QGraphicsView to create a sort of circut editor, which has elements in it, which have connectors. It should be possible to connect those connectors with wires. However I have a problem, while I drag from one connector to another, Qt grabs mouse, and other connectors stop receiving hoverEnterEvent. Btw, on hover connectors resiz...

QGraphicsView - how to disable mouse and keyboard scrolling

In my application I have QGraphicsScene with pixmap added and all is viewed in QGraphicsView with scrollbars off. The program window is smaller then pixmap and when I press arrow keys or move mouse wheel the pixmap is being moved. How do I disable that so even if the pixmap is bigger than window it won't be moved by keyboard or mouse un...

How should I use a QGraphicsScene with layouts and widgets

I'm creating some graphic data displaying widget in Qt4 and I was tempted to use the QGraphicsScene for it, create QGraphicsItems for the data items etc. However, I wanted to add some layer of controls (eg. scrollbars, zoom+other buttons - I want to make it in a similar style as eg. Google Maps, that is, the data would be displayed all ...

calling Qt's QGraphicsView::setViewport with a custom QGLWidget

I've derived from QGLWidget before, like so: class MyGLWidget : public QGLWidget { public: // stuff... virtual void initializeGL() { /* my custom OpenGL initialization routine */ } // more stuff... }; However, I find that if I try to initialize a QGraphicsView with my custom QGLWidget as the viewport, initializeGL doesn't g...

Sharing same model in two QGraphicScene instances in Qt

I have an application that displays an editor for a diagram using QGraphicsScene object. I would like to create a read only version of the same dialog but have ability for user to see both at the same time. SimScene* pScene1 = new SimScene(model); // adds model to scene SimScene* pScene2 = new SimScene(model); // adds model to scene ...

QGraphicsView and QGraphicsItem: don´t scale item when scaling the view rect

Hi, I am using Qt´s QGraphicsView- and QGraphicsItem-subclasses. is there a way to not scale the graphical representation of the item in the view when the view rectangle is changed, e.g. when zooming in. The default behaviour is that my items scale in relation to my view rectangle. I would like to visualize 2d points which should be rep...

QPixmap of a QGraphicsTextItem

How do you convert/paint a QGraphicsTextItem into a QPixmap? ...

Get visible rectangle of QGraphicsView?

I've been pulling my hair out with this one for hours. There's a thread here about it, but nothing seems to be working. QGraphicsView::rect() will return the width and height, but the left and top values aren't set properly (always 0 -- ignoring the scrolled amount). I want it in scene coordinates, but it should be easy enough to transla...

QGraphicsView with automatic items placing

I would like to write an asset browser using QGraphicsView. It's a little different from examples using QGraphicsView and QGraphicsItems, because I want only one scrollbar and I want items to move automatically, when the viewport size changes. For example, when viewport width is large enough to display 4 asssets, they should be displayed...

Getting the bounding box of a constant size item in Qt graphics views

I need to get the bounding box (in scene space) of QGraphicsItems that have the QGraphicsItem::ItemIgnoresTransformations flag set. According to the docs, you need to use QGraphicsItem::deviceTransform() to do that. I tried this: // Get the viewport => scene transform vp_trans = view.viewportTransform(); // Get the item => viewport tra...

Why does my QGraphicsView not showing up in my MainWindow in Qt4?

This is probably something very obvious, but I have a new to Qt and can't figure it out. I have a simple MainWindow which has one button. When that button is clicked I want to create a QGraphicsScene, add a few lines and then show that in the Window. However when I run this code in a Window it does not show up. BUT, if I run this as a ...

How to get QGraphicsScene report item move events

Qt's QGraphicsScene provides some nice functionality out of box: user can select objects and move them around. I want one more thing - get notifications when user has finished moving the object. There are lower level events, like mouse move, press, release, but I'd not like to reimplement the functionality that is already there (moving ...

Using items in the background of a QGraphicsScene

I have a QGraphicsScene where I initially drew the background in the drawBackground() function. However, this required quite a few calculations and turned out to be pretty slow so I created a bunch of items instead. This had the expected speedup. My question: is there a way to treat these items as the background? Would it even matter if...

QGraphicsView accepted events

Hello everyone, I am using the Qt Graphics View framework to create a scene and attach multiple views to the same scene, where these views render a 3D openscenegraph scene as background and the 2D drawings are kind of overlays. I am trying to intercept mouse/key events in my OverlayViewport class (inherits QGraphicsView) and navigate t...

Qt4: Scale invariant qgraphicsitem outlines

I am drawing some polygons using the Qt4 GraphicsView framework, and I allow the user to zoom in and out of the drawing. I would like the polygons to get larger and smaller as the user changes zoom levels (scale) in the view, but is there a way to make the outline thickness always remain the same? Thanks! ...

How to test proximity to the outline of a QGraphicsPathItem?

I'm trying to test whether a given point (x, y) is located on or close to the outline of a QGraphicsPathItem. Using QGraphicsItem.contains() or .collidesWithItem() / Path() will not do: those also return True if the point is contained within the area on the interior of the path, while I want to test only for points on the outline. How ...

How can I implement Google Maps-like tile scrolling in Qt?

I'm using Qt/C++ and trying to draw a large and complex QGraphicsScene. Once I add a lot of objects, panning and zooming become unpleasantly slow. (No surprise here, of course). I've played with device coordinate caching (helps with panning to a point) and minimal viewport updates and so on, but eventually there's just too many object...

Qt4: Locking the mouse cursor in place while manipulating QGraphicsItem...

I'm writing a little GUI utility in Qt4 which uses a QGraphicsScene. One of the items tracks the mouse in the horizontal plane as you move it around, and holding down a modifier key allows you to change the item's rotation. When rotating items I'd like the mouse cursor to change to a curvy arrow (or something) and lock visually in plac...

take a snapshop of a qgraphicsview

I am using Qt 4.5 and a qgraphicsscene/view to show video to the user. I would like to provide a "take a snapshop" button and I am sure that there is a pretty straightforward way much simpler of everything I am thinking about. How can I do this elegantly? BTW, the code is here : http://gitorious.org/handy ...

QGraphicsView and eventFilter

Hello everyone, 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 ...