November 3, 2011

xtingray xtingray
Lab Rat
94 posts

[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! :)

 Signature 

—-
Gustav Gonzalez
Development Leader
.(JavaScript must be enabled to view this email address)

Tupi: Magia 2D
http://www.maefloresta.com
—-

4 replies

November 3, 2011

Jupiter Jupiter
Lab Rat
78 posts

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.

November 3, 2011

ZapB ZapB
Ant Farmer
1442 posts

Just attach another QGraphicsView to your QGraphicsScene and set the transformation on the second view such that it is zoomed in. Take a look at the 40,000 chips demo that ships with QT to see how this is done. That demo uses 4 views onto a single scene.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

November 4, 2011

xtingray xtingray
Lab Rat
94 posts

Thank you so much guys! Now I have the hint I was looking for :)

 Signature 

—-
Gustav Gonzalez
Development Leader
.(JavaScript must be enabled to view this email address)

Tupi: Magia 2D
http://www.maefloresta.com
—-

November 4, 2011

xtingray xtingray
Lab Rat
94 posts

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 :)

 Signature 

—-
Gustav Gonzalez
Development Leader
.(JavaScript must be enabled to view this email address)

Tupi: Magia 2D
http://www.maefloresta.com
—-

 
  ‹‹ [Split] Using HTTP for data transfer      populate treelist help ››

You must log in to post a reply. Not a member yet? Register here!