[SOLVED] mainwindow pass data to dialog
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();
- }
4 replies
You may add new method for your dialog and set data into it, for example.
@
dialog.cppdialog.setData(myType myData)
{ ui.editText.setText(myData.textForEdit); …….
}…..
mainwindow.cppMainWindow::MainWindow()
{ NewDialog dialog(this); dialog.setData(myData); dialog.exec();
}
@
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…
You must log in to post a reply. Not a member yet? Register here!




