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.resize(QApplication::desktop()->width(),QApplication::desktop()->height()/1.5);
        FlatInserterDialogInstance.CopyMvar(Psstk_MultiVariabel);
        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
        ui->FI3DGlWidget->StdClass_CopyPointers(FlatInserter_MultiVariabel);
    }
    

    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

    FlatInserterDialogInstance.Display();
    

    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.


  • Qt Champions 2016

    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
    http://doc.qt.io/qt-5.5/QWidget.html#showEvent
    hope it helps.



  • thanks a bunch

    added in the .h

        void showEvent(QShowEvent * event);
    

    added in the .cpp

    void FlatInserterDialog::showEvent(QShowEvent * event){
    Display();
    }
    

    It works


  • Qt Champions 2016

    super :)


Log in to reply
 

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