Hi everybody!

This is my first time here so please bare with me

I have a mainwindow with a menu. When one press "new game" in the menu I'd like to get a new form to make setups in. My idea is to use QDialog with 2 spinboxes for selecting int values. After the OK button is pressed, the data in these two fields should then be passed to the mainwindow in some way and the QDialog is closed.

The first question is whether I should use QDialog or is there something more suitable for my needs? Some kind of form that can pass different values back to the mainwindow when the form is closed.

If I use QDialog, I have a few ideas:

Passing a function pointer (pointing to the function in the mainwindow I want to execute after I have the setupvalues) to the QDialog when I create it in the mainwindow. Then when the OK button is pressed the values are used using the function pointer.

Passing a pointer (pointing to the mainwindow) to the QDialog so that the QDialog can run the mainwindows function with the values.
Something like:
Qt Code:
  1. void SetupDialog::on_buttonBox_accepted()
  2. {
  3. mainwindow->InitializeGame(m_ui->spinBox.value, spinBox_2.value);
  4. }
To copy to clipboard, switch view to plain text mode 

Modifying the QDialog in some way so it returns a std:: pair instead of int when using QSetupDialog dialog.exec();
I tryd modifying the returnvalue in the moc_setupdialog file, but when I build the project, the code was automatically generated into the moc file and overwrited my modifications.
I wish it could it be done something like:
std:: pair<int,int> xy = new setupdialog();

The only way I have succeeded so far was to make temp variables in the function that starts the setupdialog, and pass pointers to them to the setupdialog. This way the setupdialog can access them directly and set there values when the OK button is pressed.
Something like:
Qt Code:
  1. int *x;
  2. int *y;
  3.  
  4. SetupDialog dialog = new setupdialog(x,y);
To copy to clipboard, switch view to plain text mode 

And in the setupdialog:

Qt Code:
  1. void SetupDialog::on_buttonBox_accepted()
  2. {
  3. this->x = m_ui->spinBox.value;
  4. this->y = m_ui->spinBox_2.value;
  5. }
To copy to clipboard, switch view to plain text mode 
I'd prefer some other solution than this. I don't like the QDialog to setting the values in the mainwindow directly.

Thanks for any help!