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. Access the function of another window.
Forum Updated to NodeBB v4.3 + New Features

Access the function of another window.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 174 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.
  • K Offline
    K Offline
    kipalex
    wrote on last edited by
    #1

    Hello.
    There is a program in it there is a MainWindow window and a Configuration settings window.
    The ReadXML function is called inside the Configuration window. Everything works, but I will not mind how you can call this very function (ReadXML) when starting the MainWindow. I looked and read the literature and recommend using slots and signals.
    What I tried to do:
    In the mainwindow.h file, I added the signals

    signal:
    void credentials();
    

    In the configuration.h file, I added the

    public slots slot:
    void ReadXML();
    

    And at the very beginning of the program in the mainwindow.cpp file, I tried to connect

    ui- > setupUi (this);
    connect(this, &MainWindow::credentials, &Configuration::Configuration, &Configuration::ReadXML);
    

    Please tell me how to do it.

    JonBJ 1 Reply Last reply
    0
    • K kipalex

      Hello.
      There is a program in it there is a MainWindow window and a Configuration settings window.
      The ReadXML function is called inside the Configuration window. Everything works, but I will not mind how you can call this very function (ReadXML) when starting the MainWindow. I looked and read the literature and recommend using slots and signals.
      What I tried to do:
      In the mainwindow.h file, I added the signals

      signal:
      void credentials();
      

      In the configuration.h file, I added the

      public slots slot:
      void ReadXML();
      

      And at the very beginning of the program in the mainwindow.cpp file, I tried to connect

      ui- > setupUi (this);
      connect(this, &MainWindow::credentials, &Configuration::Configuration, &Configuration::ReadXML);
      

      Please tell me how to do it.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @kipalex said in Access the function of another window.:

      signal:

      public slots slot:

      Please start by correcting these for yourself so it compiles. You did not find either of these out there on the web. Use the documentation or examples, there are so many you don't need to make someone else write it for you. Though see below as you may not need either.

      connect(this, &MainWindow::credentials, &Configuration::Configuration, &Configuration::ReadXML);

      &Configuration::Configuration is incorrect. It requires a pointer to the slot object. If you are creating a "Configuration window" as you say then use the instance here.

      If the main window creates the configuration window then there is no point having a signal, connecting and emitting. It might as well just call Configuration::ReadXML() when it wants to.

      1 Reply Last reply
      1

      • Login

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