Questions tagged [qgraphicsview]

A QGraphicsView is a class from the Qt toolkit which provides a widget for displaying the contents of a QGraphicsScene.

The QGraphicsView class is part of Qt's Graphics View Framework and is used to visualize the contents of a QGraphicsScene in a scrollable viewport.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

1128 questions
32
votes
13 answers

QGraphicsView Zooming in and out under mouse position using mouse wheel

I have an application with a QGraphicsView window in the middle of the screen. I want to be able to zoom in and out using a mouse wheel scroll. Currently I have re-implemented QGraphicsView and overriden the mouse scroll function so that it doesn't…
AngryDuck
  • 4,358
  • 13
  • 57
  • 91
31
votes
5 answers

GIF animation in Qt

I have used QGraphicsView, QGraphicsScene classes in order to show a picture in a widget like this: m_Scene->addPixmap(QPixmap(fileName)); m_View->setScene(m_Scene); How I can show .gif animation in the same scene?
Narek
  • 38,779
  • 79
  • 233
  • 389
25
votes
3 answers

how to pan images in QGraphicsView

I am currently able to load my image into a grahpics scene, and then again into a QGraphicsViewer. I am able to implement a zoom feature by dtecting a QEvent::Wheel and then calling the graphicsViews's scale() function. However, I can't seem to…
Derek
  • 11,715
  • 32
  • 127
  • 228
23
votes
2 answers

Tracking mouse move in QGraphicsScene class

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…
cuteCAT
  • 2,251
  • 4
  • 25
  • 30
23
votes
3 answers

How to enable Pan and Zoom in a QGraphicsView

I am using python and Qt Designer to implement loading tiff images and to enable Pan and Zoom on some mouse event (wheel - zoom, press wheel - pan). I was looking into some options and classes that can work with images etc, and so far I have found:…
milutinke
  • 401
  • 1
  • 4
  • 13
23
votes
2 answers

QGraphicsItem doesn't receive mouse hover events

I have a class derived from QGraphicsView, which contains QGraphicsItem-derived elements. I want these elements to change color whenever the mouse cursor hovers over them, so I implemented hoverEnterEvent (and hoverLeaveEvent): void…
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
22
votes
1 answer

How to set QGraphicsScene/View to a specific coordinate system

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 | …
QLands
  • 2,424
  • 5
  • 30
  • 50
18
votes
1 answer

How to use Qt Model/View framework with the Graphics View framework

I am working on a mapping application and need to display the data objects using a table, a form and as graphical objects in the map. I'm using PyQt, but that's not really important as this is a Qt question not a Python question. If I only needed…
Simon Hibbs
  • 5,941
  • 5
  • 26
  • 32
18
votes
6 answers

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…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
18
votes
3 answers

Can I get mouse events in a QGraphicsItem?

I have subclassed QGraphicsRectItem, and it's not receiving any mouse events. I've seen other questions similar to this say I need to enable mouse tracking, but setMouseTracking is in QWidget, and QGraphicsItem does not appear to be a QWidget. I've…
Almo
  • 15,538
  • 13
  • 67
  • 95
16
votes
2 answers

How to optimize QGraphicsView's performance?

I'm developing a CAD application using Qt 5.6.2 that is required to run in cheap computers at the same time that it needs to handle thousands of items in the same scene. Because of that, I had to make a lot of experimentations in order to get the…
Adriel Jr
  • 2,451
  • 19
  • 25
16
votes
4 answers

Why is a rectangle partly outside of view drawn as a triangle?

I use the Python-Qt bindings from PySide and I want to draw a scene with amongst others a rectangle and the rectangle is not fully visible because the view should only show a part of the scene where the rectangle is not fully contained. Here is a…
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
16
votes
5 answers

Image doesn't fit graphics view frame

I'm working on program which shows users some picture they select. I would like to fit this picture in QGraphicsView's frame, but the picture appears smaller than the frame. So here's my code: image = new QImage(data.absoluteFilePath()); // variable…
user1257255
  • 1,161
  • 8
  • 26
  • 55
14
votes
2 answers

Qt Graphics View , show image ! , Widget

Here is my code : void MainWindow::on_actionOpen_Image_triggered() { QString fileName = QFileDialog::getOpenFileName(this,"Open Image File",QDir::currentPath()); if(!fileName.isEmpty()) { QImage image(fileName); …
Davit Tvildiani
  • 1,915
  • 3
  • 19
  • 29
13
votes
2 answers

PyQt: Trying to understand graphics scene/view

I'm trying to make sense of QGraphicsView and QGraphicsScene, specifically how to place graphics items and have them appear where I want them to. I'm also confused about when scroll bars will appear if the scene is larger than the viewing area. For…
XandYandZ
  • 283
  • 1
  • 3
  • 9
1
2 3
75 76