[solved] Exporting a QGraphicsView from one QFrame to another
Hello there!
For these days I have been thinking of a new feature for my project. Currently the application has a canvas where users can draw simple vectorial lines, but I would like to provide the next option:
- When users do “Ctrl+Something” I want that a new QFrame shows up, covering the whole screen and containing a copy of the canvas (including all the graphic objects). Basically the idea is to offer a “zoom experience” (full screen) of the canvas. In my dreams, I would love that if users draw over the new QFrame (full screen), all the new changes appear in the original (small) canvas. Finally, when users want to back to the normal interface, they just have to press “Esc” key and that’s all.
For some weird reason I’m thinking that there’s a chance of make this feature come true using a QGraphicsView, nevertheless I’m just guessing, because it’s not just a “Zoom tool”, understanding that events over the full screen QFrame must be reflected into the original canvas.
Taking advance of the many experts around this forum… I would like to read comments/advices/ideas about how to design this feature. Is this possible? am I just dreaming? or in fact, is it simpler than I thought?
Thanks! :)
4 replies
a graphicsScene can have several views. so you work with one scene in your regular view. then pass the pointer to the new, zoomed view (it can also show a different part of the scene) and show in on to of your regular view.
all changes on an item will appear on both views then, because the scene is actually the data model of the view.
Qt is incredible! I got the solution in few lines relatively:
1. I create a QDialog based class with my QGraphicsScene object (scene) as constructor parameter
2. Inside the QDialog I created a QGraphicsView variable (graphicsView)
3. I set the Scene to the View doing: graphicsView->setScene(scene);
4. I included the QGraphicsView object inside the Layout of the QDialog:
layout->addWidget(graphicsView);
5. When I open the dialog… voilĂ !
I need to work in some details around, but the result is impressive!
Thank you again guys :)
You must log in to post a reply. Not a member yet? Register here!



