I have an MDI application, with classes as
class MainWindow
{ GraphicsView *gv; };
class GraphicsView
{ Scene *scene; };
class Scene
I'm creating a new mdiSubWindow on every newfile()
of MainWindow
which creates a new pointer to the GraphicsView.
void MainWindow::newFile()
{
gv = new GraphicsView;
QMdiSubWindow *w = mdiArea->addSubWindow(gv);
mdiArea->setActiveSubWindow(w);
}
And the constructor of GraphicsView
creates a new Scene.
GraphicsView::GraphicsView()
{
scene = new Scene;
setScene(scene);
}
Now when there are multiple subWindows created, I lose the ability to work in previous subWindows. Only the latest subWindow works as expected. For eg. I can draw QGraphicsItems
only in the latest Sub Windows and not in the previous ones.
I think I should be using activeSubWindow()
but couldn't figure out how to make every subWindow respond to the change of the tabs. How should I implement this?
To make it work.
I've created a
QList<QPair>
, for storing a pair of subwindow and view.Then
subWindowActivated()
signal is used to call the following function to update the view pointer.