Interaction between dialog boxes and main window

  • Hello All,

    Please help me to get interaction(passing some values) between dialog-dialog and dialog-main window.
    It would be very helpful if you provide some code or links for similar examples.

    Any suggestion appreciated.
    Thanks in Advance


  • It is not really clear what you mean, some code will be helpful. In any way the answer will be: use signal/slot connection to communicate between objects... Here is video tutorial: "C++ Qt 04 - Signals and Slots":

  • Thanks for the reply,

    I am trying to make it more clear:

    • I am trying to create some dialogs, which will return some value to the another dialog (which exec() or show the first dialog )when we close these.

    I have tried to write the close event , but don't know how a dialog returns a value to its parent.

    I want to have a three level dialog calling system .(mainWindow -> dialog -> subDialog).
    And the values will be returned in a manner like.(subDialog -> dialog -> mainWindow).

    Please help me for this.

    Any suggestion appreciated.

    Thanks and Regards


  • Like AcerExtensa told you: use signals and slots.

    In your case, you could emit a signal from subDialog in closeEvent, which will be connected to dialog and then from dialog to mainWindow.

    Another way could be to use a defined value with QDialog::done().

  • if you want passing arguments.. this example illustrates pass a int value as an argument in
    signal/slot mechanism.

    in header file

    Q_PROPERTY(int curState READ curState NOTIFY changeState)

    int curState();

    void changeState(int);

    in CPP

    int ClassName::curState() // write a get method in cpp
    return crstate;

    Now you can use signal/slot mechanism whatever you want either
    interaction(passing some values) between dialog-dialog and dialog-main window
    or other.

  • in the above code
    emit a signal "changeState" from Dialogbox in closeEvent, which will be pass value from dialog to dialog or from dialog to mainWindow.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.