I would like to split up the code of my application into multiple classes, each class containing a dockwidget with its underlying functionality.

For that I would like to have access to the original "ui" from my mainclass, since the dockwidgets need to change functionality in the main window. How can I connect this?

I have managed to pass the "ui" to a function, but i cant figure out how to store it inside the new object.
Any other approaches to solve this problem are also welcome.


Qt Code:
  1. #ifndef SUBCLASS_H
  2. #define SUBCLASS_H
  3. #include <ui_mainclass.h>
  4.  
  5. namespace Ui {
  6. class MainClass;
  7. }
  8.  
  9. class SubClass
  10. {
  11. private:
  12. Ui::Ui_MainClass *ui;
  13. public:
  14. DataGeneration(Ui_MainClass *myUi);
  15. }
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. NewSubclass::NewSubclass( Ui_MainClass *myUi)
  2. {
  3. qDebug() << myUi->tableWidget->rowCount(); // works
  4.  
  5. ui = myUi // does not work
  6. }
To copy to clipboard, switch view to plain text mode