C++ Qt 81 - QGraphicsView and QGraphicsScene
Why Stack Overflow recommends it
Stack Overflow users link it when pointing Qt newcomers to the QGraphicsView framework for 2D drawing and for manipulating items in a scene.
Recommended by 2 people across 2 different months, 2012 to 2016.
What it is
A short C++ Qt tutorial from VoidRealms, part of a long numbered series, introducing QGraphicsView and QGraphicsScene. It shows how a scene holds 2D items and a view displays them, using code examples.
What people said
Strong rec Anthony · 2012-10 · Stack Overflow · on “QT Widget Pointer”
I second the need to switch to the QGraphicsView framework, rather than creating QWidgets. This is the best QGraphicsView tutorial [this video] . There is also the "official" one [LINK] .
Recommends Gaurav Raj · 2012-12 · Stack Overflow · on “Graphicsitem/ pixmap not displaying in graphics scene”
Your scene setup seems fine. You can check if your scene works properly by adding QGraphicsRectItem at any desired position on the scene. Adding pixmap to your existing scene - QGraphicsPixmapItem *newItem=new QGraphicsPixmapItem(QPixmap(":/Single_linked_list.png")); scene->addItem(newItem); This will add the pixmap item to the scene as well as show it. You don't need to call it explicitly to show the image. If you want to apply normal animations like translation, rotation or scaling, you can simply use the setPos, setScale or setTransform functions. For better control, you can use Animation Framework provided by Qt. It applies to any QGraphicsItem i.e. also QGraphicsPixmapItem. Check out th
Cites Son-Huy Pham · 2013-06 · Stack Overflow · on “How to Zoom a Video in Qt (QVideowidget)?”
Looks like you need to place a video item [LINK] into a graphics scene [LINK] . This will allow you to resize the video and essentially "zoom" in. You can google for tons of tutorials on how to manipulate items [this video] in the scene - they should all work in a similar fashion to other 2d items. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); player = new QMediaPlayer(this); player->setMedia(QUrl::fromLocalFile("video.mp4")); videoItem = new QGraphicsVideoItem(); player->setVideoOutput(videoItem); ui->graphicsView->setScene(new QGraphicsScene()); ui->graphicsView->scene()->addItem(videoItem); }
Cites smilingbuddha · 2016-04 · Stack Overflow · on “Difference between drawing with QPainter and (QGraphicsView + QGraphicsScene)”
I am new to the QT libraries, and I wanted to know what the difference is between QPainter and QGraphicsScene. From what I understand by seeing voidrealms videos with QPainter [LINK] and with QGraphicsView + QGraphicsScene [this video] with both you can draw complex 2d objects. The main difference being in the latter have an arbitrarily large scene which we view through a "window" (I believe Qt guys call it viewport?) and that this scene can be scrolled with side-bars. Also we can interact with drawings made in a GraphicsView widget, say with a mouse, but in a QPainter we cannot. Is this correct? In what use cases do we use QPainter and when do we use QGraphicsScene+QGraphicsView? I am primarily