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. [SOLVED] mainwindow pass data to dialog

[SOLVED] mainwindow pass data to dialog

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 14.2k Views
  • 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 Offline
    X Offline
    xeroblast
    wrote on last edited by
    #1

    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
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      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
      0
      • X Offline
        X Offline
        xeroblast
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • B Offline
          B Offline
          baysmith
          wrote on last edited by
          #4

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

          Nokia Certified Qt Specialist.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koleygr
            wrote on last edited by
            #5

            [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
            0

            • Login

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