Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] mainwindow pass data to dialog

    General and Desktop
    4
    5
    13763
    Loading More Posts
    • 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.
    • X
      xeroblast last edited by

      hi,

      i have this problem that dont know how to implement it.

      i have this mainwindow that have a qtablewidget that you select an item in the qtablewidget and click the button to view its details.

      the problem is i dont know how to pass the data from qtablewidget to the newly opened qdialog. i know how to get the data in the qtablewidget but i dont know how to pass it to qdialog.

      this is how i open a qdialog..
      @
      MainWindow::MainWindow()
      {
      NewDialog dialog(this);
      dialog.exec();
      }
      @

      1 Reply Last reply Reply Quote 0
      • V
        vsorokin last edited by

        You may add new method for your dialog and set data into it, for example.
        @
        dialog.cpp

        dialog.setData(myType myData)
        {
        ui.editText.setText(myData.textForEdit);
        .......
        }

        .....
        mainwindow.cpp

        MainWindow::MainWindow()
        {
        NewDialog dialog(this);
        dialog.setData(myData);
        dialog.exec();
        }
        @

        --
        Vasiliy

        1 Reply Last reply Reply Quote 0
        • X
          xeroblast last edited by

          thanx. i got it now and really thank you...

          1 Reply Last reply Reply Quote 0
          • B
            baysmith last edited by

            xeroblast, note that the markup for code is "@...@", not [CODE][/CODE]

            Nokia Certified Qt Specialist.

            1 Reply Last reply Reply Quote 0
            • K
              koleygr last edited by

              [quote author="Vass" date="1292048493"]You may add new method for your dialog and set data into it, for example.
              @
              dialog.cpp

              dialog.setData(myType myData)
              {
              ui.editText.setText(myData.textForEdit);
              .......
              }

              .....
              mainwindow.cpp

              MainWindow::MainWindow()
              {
              NewDialog dialog(this);
              dialog.setData(myData);
              dialog.exec();
              }
              @[/quote]

              I tried this method and it's fine... it solved many problems i had with external variables...

              The problem is that if i don't use a pushbutton or something the dialog don't realy recognize my new data...

              I can't understand why...

              Edit: I finally dont need to use my variables before a simple click...
              I suppose this is why we call it a dialog...

              Using:Qt Creator 2.4.1 under UBUNTU

              1 Reply Last reply Reply Quote 0
              • First post
                Last post