Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiple QMainWindow instances

Multiple QMainWindow instances

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    viniltc
    wrote on last edited by
    #1

    Hi all,

    I'm working on an application which has multiple QMainWindow instances. I named those as:
    StageOneMain, StageTwoProg and StageThreeProg 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 the tetra_grip_api instance to constructor of StageOneMain. So my main looks like this

    int 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 of tetra_grip_api to the constructor of other forms. Do I need to mention those forms in the main?

    Thanks in advance

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      If you store the API pointer in your StageOneMain, you can pass it to StageTwo and StageTree when you construct them.

      (Z(:^

      1 Reply Last reply
      4
      • V Offline
        V Offline
        viniltc
        wrote on last edited by
        #3

        @sierdzio Thanks a lot for the clarification

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved