Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display contents of vector in dialog widget when dialog is executed
Forum Updated to NodeBB v4.3 + New Features

Display contents of vector in dialog widget when dialog is executed

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 962 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steven
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Steven
        wrote on last edited by
        #3

        thanks a bunch

        added in the .h

            void showEvent(QShowEvent * event);
        

        added in the .cpp

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

        It works

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          super :)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved