Multiple QMainWindow instances
Solved
General and Desktop
-
Hi all,
I'm working on an application which has multiple QMainWindow instances. I named those as:
StageOneMain
,StageTwoProg
andStageThreeProg
etc.I also have another class say
tetra_grip_api
, need to be accessed in all of these forms (which is like an API).StageOneMain
is the first window , I pass the pointer to thetetra_grip_api
instance to constructor ofStageOneMain
. So mymain
looks like thisint main(int argc, char *argv[]) { QApplication a(argc, argv); tetra_grip_api api; api.openSerialPort(); StageOneMain w(nullptr, &api); w.show(); return a.exec(); }
Other windows will be called from
StageOneMain
. My question is where do I pass instance oftetra_grip_api
to the constructor of other forms. Do I need to mention those forms in themain
?Thanks in advance
-
If you store the API pointer in your StageOneMain, you can pass it to StageTwo and StageTree when you construct them.