Not a problem, that's what these forums are for.
To call the second window you need to first instantiate the calling window and then execute it. It might look like this:
void MainWindow::openNewWindow()
{
EditWindow myEditWindow(); // call the constructor of the second window
myEditWindow.exec(); // This executes the window, and it will pop up
if (myEditWindow.
result == QDialog::Accepted) {
// Write your code here to retrieve what ever you want from the second window.
// In the Second window you will need to create a slot for accept(), code below
}
//You can then close or hide the second window
myEditWindow.close();
}
void MainWindow::openNewWindow()
{
EditWindow myEditWindow(); // call the constructor of the second window
myEditWindow.exec(); // This executes the window, and it will pop up
if (myEditWindow.result == QDialog::Accepted)
{
// Write your code here to retrieve what ever you want from the second window.
// In the Second window you will need to create a slot for accept(), code below
}
//You can then close or hide the second window
myEditWindow.close();
}
To copy to clipboard, switch view to plain text mode
In the Second window write the slot for accept() and link it to the 'clicked' signal (This depends on the buttons you have on your ui to close the second window Eg OK | Cancel or is it more buttons Eg: Save | Save All | Cancel).
Using the accept() helps to link it to the appropriate button
EditWindow.h file
slot
accept(); // For OK or Save
reject(); // For cancel
slot
accept(); // For OK or Save
reject(); // For cancel
To copy to clipboard, switch view to plain text mode
EditWindow.cpp file
connect (ui.OKButton, SIGNAL(clicked()), this, SLOT(accept()));
void EditWindow::accept()
{
//And whatever other code you might want to put here Eg validate before closing the window etc
}
connect (ui.OKButton, SIGNAL(clicked()), this, SLOT(accept()));
void EditWindow::accept()
{
QDialog::accept();
//And whatever other code you might want to put here Eg validate before closing the window etc
}
To copy to clipboard, switch view to plain text mode
Read the documents (Qt Assistant) for QDialog() and you will see the other slots there Eg open(), exec() etc
Good luck!
Bookmarks