Important: Please read the Qt Code of Conduct -

Display contents of vector in dialog widget when dialog is executed

  • I think this is something obvious but i can't find the right search query on google.

    I got a std::vector which gets passed to a dialog and should be displayed in a glwidget when the dialog is shown.

    //this calls the dialog and copies my vector into the dialog

    void PasstukDialog::on_InsertFlat_pushButton_clicked()
     FlatInserterDialog FlatInserterDialogInstance;
        FlatInserterDialogInstance .exec();

    Now when I make a pushbutton in the dialog and make it call the display()

    void FlatInserterDialog::Display()
    {//copies content to the glwidget which paints it on the screen

    function it displays the contents of the vector in the glwidget(which is in the dialog)

    but i would like to load it when the dialog is shown without the user having to push a button first

    What seems to happen though is the constructor of the dialog is executed first.
    Then the vector is copied.
    Then the dialog gets displayed.

    So when i try something like


    The dialog isnt shown yet .

    I would need a signal when the dialog is loaded to display the content of the vector automatically. but there is only a close signal.

  • Lifetime Qt Champion

    Hi and welcome
    Even I read you post a few times, im not 100% sure what the real problem
    is as you could setup all u need before calling exec().
    So I must be missing something.

    But you seem to want to know when dialog is shown and
    that you can know with
    hope it helps.

  • thanks a bunch

    added in the .h

        void showEvent(QShowEvent * event);

    added in the .cpp

    void FlatInserterDialog::showEvent(QShowEvent * event){

    It works

  • Lifetime Qt Champion

    super :)

Log in to reply