Answer the question
In order to leave comments, you need to log in
How to implement two-way communication between C++ MainWindow mdiSubWindow GraphicsScene classes?
There is an MDI application based on MainWindow.
MainWindow contains a lot of DockWidgets, inside of which I placed toolboxes and a properties window for elements.
Child windows contain the "left" QWidget (which he defined himself) with QGraphicsView stretched to the full width and height of the widget, taking up all its space. Inside the same widget, I create an object of the QGraphicsScene class, also custom.
Task:
in addition to the ability to access from MainWindow directly to the scene, for example, to read data from an array and change the order and toolboxes in accordance with the contents of the document from objects (for example, when switching between child windows, we already have this). But also to provide the ability to "call" the MainWindow directly from the scene, for example, I selected an element, and I want to immediately display its characteristics in the properties panel located in the MainWindow, either by clicking on the element or by using the context menu command.
Answer the question
In order to leave comments, you need to log in
Well, I solved the problem myself!
Sharing with those who are asking the same question:
To do this, I used the "outer pointer" method to provide scene feedback to the MainWindow.
Thanks for the tip to one of my Austrian friend.
1) create a static pointer (just in case, I packed it inside the class)
class MainWinConnect
{
public:
static MainWindow * pMainWin;
};
class MainWindow
{
public:
void callMe(int someData);
...
MyScene * scene;
}
void MyScene::doSomething()
{
...
MainWinConnect::pMainWin->callMe(1234);
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question