Avatar ·

How to properly convey an object from one class to another?

📁 method, example, AI

There are two classes: MainWindow and SetOfButtons ,
the first class is the main class,
and the second class must build buttons on the skeleton of the window.

So, how can you properly pass the window object to the buttons so that you can completely control this object from the buttons class?

I already tried to create an object of the SetOfButtons class when initializing the MainWindow class and pass the window to it, it turned out to build buttons, but when it came to checking for pressing and performing any action, everything broke.

Help please. Below I give an approximate code of two classes.