Multiple QMainWindow instances
-
Hi all,
I'm working on an application which has multiple QMainWindow instances. I named those as:
StageOneMain,StageTwoProgandStageThreeProgetc.I also have another class say
tetra_grip_api, need to be accessed in all of these forms (which is like an API).StageOneMainis the first window , I pass the pointer to thetetra_grip_apiinstance to constructor ofStageOneMain. So mymainlooks 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_apito 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.