drawing shapes onto QPixmap with QPaintEvent
-
@mrjj yes exactly! but when I zoom in and out I would like there to be a scrollbar so that I can view and edit the entire image and not just the upper part.
Well im asking as you use the GraphicsView in a (in my opinion) odd way
as you treat it like the QWidget paint.
Normally one would use
https://doc.qt.io/qt-5/qgraphicspixmapitem.html
for the image and and make a custom QGraphicsItem to handle the overlay points
and in other ways used the features of the QGraphicsScene/view.Where are you seem to directly draw on the view as a normal Widget.
Its not criticism! i just wondered if you needed all of the QGraphicsScene/view stuff as doing with just a QWidget and paint is far more simple if
all the other features is not needed.And when you just overwrite paint for view (as the code you shown), then you are not using ANY of the selection/grouping/scaling etc of the Graphics Framework.
So i had to ask :) -
Well im asking as you use the GraphicsView in a (in my opinion) odd way
as you treat it like the QWidget paint.
Normally one would use
https://doc.qt.io/qt-5/qgraphicspixmapitem.html
for the image and and make a custom QGraphicsItem to handle the overlay points
and in other ways used the features of the QGraphicsScene/view.Where are you seem to directly draw on the view as a normal Widget.
Its not criticism! i just wondered if you needed all of the QGraphicsScene/view stuff as doing with just a QWidget and paint is far more simple if
all the other features is not needed.And when you just overwrite paint for view (as the code you shown), then you are not using ANY of the selection/grouping/scaling etc of the Graphics Framework.
So i had to ask :)@mrjj okay, but I still don't get how to use the QGraphicsScene/View now.
Do I make the ScrollArea a QGraphicsView and then load the QGraphicsPixmap into the QGraphicsView?I don't really get the structure that is needed for this.
-
@mrjj okay, but I still don't get how to use the QGraphicsScene/View now.
Do I make the ScrollArea a QGraphicsView and then load the QGraphicsPixmap into the QGraphicsView?I don't really get the structure that is needed for this.
Hi
Normally the one would use QGraphicsPixmapItem
and maybe a custom item for the lines/polygon.
You would not need a ScrollArea -
Hi
Normally the one would use QGraphicsPixmapItem
and maybe a custom item for the lines/polygon.
You would not need a ScrollArea@mrjj Okay so I tried to make a new graphicsview and this is the code.
It doesn't seem to load the pixmap.
It's probably a stupid mistake (I make them a lot), since I've wasted way too much time on this.#include "graphicsview.h" GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent) { scene = new QGraphicsScene(this); setScene(scene); } void GraphicsView::open() { filename = QFileDialog::getOpenFileName(this,tr("Open File"), QDir::currentPath(), tr("Image Files(*.png *.jpg *.jpeg)")); qDebug() << filename; QGraphicsPixmapItem *pixmap = scene->addPixmap(QPixmap(filename)); update(); }