Hi

I'm new to these forums and new to the world of Qt.

Currently I'm working on a small assignment that asks me to create a window containing a label and a push button. When you click the button a new window should be generated, containing a line edit element (for the user to write something) and a push button. When you hit the button in this window, the window should close and the label in the first window should be updated with the text written in the line edit element (The second window is more or like a copy of QInputDialog). I would like to add that I do not use any designer for this project.

I'm able to build the windows as required, but I am not sure how to generate/call the second window from the first one.

I've named my classes MainWindow (containing a label and a push button) and EditWindow (containing line edit and push button). Both classes inherits from QDialog.

In MainWindow I use the push button clicked as a signal and I've named the slot openNewWindow:
Qt Code:
  1. connect(newWindowButton, SIGNAL(clicked()), this, SLOT(openNewWindow()));
To copy to clipboard, switch view to plain text mode 

The slot:
Qt Code:
  1. void MainWindow::openNewWindow(){
  2. //QString txt = QInputDialog::getText(this, tr("Write text"), tr("Write some text:"));
  3.  
  4. //returnLabel->setText(txt);
  5.  
  6. // Some code to open a new window (EditWindow)
  7. }
To copy to clipboard, switch view to plain text mode 

As you can see I've tested the slot using QInputDialog and applying the text returned to returnLabel (the naming of the variables might be a bit bad).

What I want to do in the slot is to open a the second window (EditWindow), but I'm not sure what the correct syntax for this would be to do this. I'm comfortable with one window, but not two or more.

This is probably simple, but not being very confident in my own abilities in Qt at the moment, I would greatly appreciate some tips or suggestions.

I hope this post is understandable, as English is not my first language.

Regards,

André