0

I have a custom QGraphicsView and a custom QGraphicsScene class. When I create a new custom view I pass in the custom scene to the constructor which calls setScene() on it. But later I am having problems when I call views() on my scene class and it is returning it as a QList I think I need to override the views() function but I'm not entirely sure what I would do differently inside of it.

Also I actually have two custom scene classes but I use the same view. I'm having trouble making two different constructors:

my_view(my_scene1 * scene, QWidget *parent =NULL);
my_view(my_scene2 * scene, QWidget *parent =NULL);

It causes many "incomplete type" errors across my other files that normally worked fine.

1 Answers1

1

It sounds like you're missing the point of QGraphicsView and QGraphicsScene. Think of the QGraphicsScene as a world with objects in that world. A QGraphicsView is like a window, or camera looking into the world (QGraphicsScene).

With that in mind, it makes sense to have multiple views looking into a single scene, but you would not have multiple scenes linked to a single view.

When you call views() on a QGraphicsScene, it returns a list because it is a list of all the QGrahicsViews that are looking at an area of the scene.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • The reason for the 2nd scene is because it is for a pop up like window when I click on a graphic in the original scene. It was just programmed that way before I took over. I'd like to add some new zoom hotkeys and features to both views (the main view and the view for the pop up box). Originally the default QGraphicsView class was used in both cases, but I wrote a subclassed view for the pop up and was able to get my zoom features to work, but when I try to use my custom view for the main scene I get compile errors. And yea this is a poorly worded question so I'll probably delete or change it. – RidesTheShortBus Nov 13 '13 at 20:49