Accessing mainwindow from another class
-
Hello guy's,
i have tried to include the mainwindow header to another class, lets call that class A, and from that class A then add a dock to the main window.
The problem is, that mainwindow already uses class A and has its header file included. So i get a circular dependency.
If i use forward declaration in class A and type "class MainWindow;" i can not really use any functions of the main window class in class A.
Is there someone with the same problem, or does someone have a solution on how to access the mainwindow class without a circular dependency?
Thanks a lot
Michael -
Hi,
If you want to communicate with your main window, use signals and slots.
The fact that you start to have circular dependencies of that kind in a GUI application hints at an architectural issue.
-
Hello guy's,
i have tried to include the mainwindow header to another class, lets call that class A, and from that class A then add a dock to the main window.
The problem is, that mainwindow already uses class A and has its header file included. So i get a circular dependency.
If i use forward declaration in class A and type "class MainWindow;" i can not really use any functions of the main window class in class A.
Is there someone with the same problem, or does someone have a solution on how to access the mainwindow class without a circular dependency?
Thanks a lot
Michael -
@tiegert said in Accessing mainwindow from another class:
i have tried to include the mainwindow header to another class
Why? Don't. And then your issue will go away.
-
Hi,
If you want to communicate with your main window, use signals and slots.
The fact that you start to have circular dependencies of that kind in a GUI application hints at an architectural issue.
-
Hi,
If you want to communicate with your main window, use signals and slots.
The fact that you start to have circular dependencies of that kind in a GUI application hints at an architectural issue.