0
votes

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

1 Answers

1
votes

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.