Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[solved] Drawing on top of an image
I would like to draw rectangles on top of an image, but so that they remain as elements of their own, allowing me to select them as well as to remove them.
So far I've added an label with an attached pixmap, adding an Qpainter to the image and then drawing on top of this. However, if I understand it correctly (new to qt) this will draw on to the pixmap itself making the image static. I would like the rectangles to "float" on top of the image so that I could select them and have action attached to them (among other to delete them). Also I'd like a "lasso like" effect when drawing the rectangles.
I'd appreciate any tips how to proceed. :) Thank you!
Found some information about how to use a graphicsview to complete this task. Unfortunately I can't post the solution as it's in a book.
But you can cite the concept ;) and the direction of your solution.
And, obviously, the book bibliography too. We all can read :D
A book that has the GraphicView well documented (for my purpose, in my opinion) is:
C++ GUI Programming with Qt4, Second edition
The principle was to create a QGraphicsView and a scene on top of which different graphics elements can be created and managed independently.
ui->setupUi(this); // QGraphicsView added via designer
scene = new QGraphicsScene(); scene->addPixmap(QPixmap("C:/test/ab.png")); ui->graphicsView->setScene(scene); ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
Still working out the details of the individual elements...
[edit : please use @ tags around your code as I did for you, Eddy]
Many thanks, this is really useful. I have a lot of book on C++ but this maybe a idea. I am approaching to develop some GUI stuff in a multiplatform environment :)