Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

how to pass a value from QDialog to another QDialog



  • how to pass a value from Dialog to another Dialog?



  • @davidlabib create a setter in the receiving Dialog class, quick pseudocode example:

    class DialogSender : public QDialog {
    ...
    }
    
    DialogSender::on_button_X_clicked() {
       DialogReceiver receiverDlg();
       ...
       receiverDlg.setValueX(the value to set from DialogSender)
    ...
    }
    
    class DialogReceiver : public QDialog {
    ...
    public:
        void setValueX(WhateverType value);
    
    }
    
    ....
    
    void AnotherClass::doWork() {
        dialogSender = new DialogSender();
        dialogSender.exec(); 
    }
    

    Or you can have the dialogs connected via signals and slots

    PS: please update/fix the title of your post so other people can find it meaningful



  • is editing the contractor of the receiving dialog a good idea ?


  • Lifetime Qt Champion

    @davidlabib
    contractor = constructor ?
    Yes, its very fine to change it to give dialog any data it needs.


Log in to reply