Important: Please read the Qt Code of Conduct -

Sending data when a window is closed

  • Hi,

    I want to send data of a window when that window is closed.
    I have one main window and some other sub windows. I press some button in main window which opens a sub window. In sub window some line edits are there which user can edit or leave it as it is. When the user presses the next button present on the sub window, it opens another sub window which again asks for some data. At this time first sub window is closed. I want that entered data ONLY when the person presses next button. I have a function in sub window which I am calling in Main window to extract values but it is always sending the default entered values i.e. as soon as sub window opens it calls the function and default values are sent.
    One way is to call that function only when window is closed. For that I was planning to edit the window->finished() signal such that when window is finished it sends some arguments which will call a slot with same number of arguments. Although I don't know how to do it!!

    Please help.

  • Lifetime Qt Champion

    Hi and welcome
    what you can do is to make a new signal in the
    sub window that has the Next button.

    void DataReady();

    then make a slot in mainwindow
    connect your new signal with you new slot.

    Then in the Next Dialog
    in the Next button pressed
    you can
    emit DataReady()
    and then mainwindow slot can grab the data.

  • I defined a function with zero variables, so that It can be used it with window->finished() signal. Then called the desired function in the body. This solved the problem.


  • Lifetime Qt Champion

    ok super.