Hello everybody,
I have just started using Qt, and immediately I found the first difficulties in understanding the use of signal / slot.
The problem is simple: I have a window (QWidget) with a QlineEdit and a button: I would like that, after typing a text in the Qline and pressing the button, another window (QWidget) would open with a QlineEdit field, filled with the text previously entered.
I can do the reverse (from first page open the second page, and from here -pressing a button - to fill the parent window), but it seems that in my code there is no link between the signal and the generated window slot ... I found this topic: http://www.qtcentre.org/threads/2398...ows?highlight=
but I can't apply the suggestions.

Page1.h:
Qt Code:
  1. #ifndef PAGE1_H
  2. #define PAGE1_H
  3.  
  4. #include <QWidget>
  5.  
  6. namespace Ui {
  7. class Page1;
  8. }
  9.  
  10. class Page1 : public QWidget
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit Page1(QWidget *parent = 0);
  16. ~Page1();
  17. signals:
  18. void transfer(QString);
  19.  
  20. private:
  21. Ui::Page1 *ui;
  22.  
  23. private slots:
  24. void on_pushButton_clicked();
  25.  
  26. };
  27.  
  28. #endif // PAGE1_H
To copy to clipboard, switch view to plain text mode 

Page1.cpp:
Qt Code:
  1. #include "page1.h"
  2. #include "ui_page1.h"
  3. #include "page2.h"
  4. Page1::Page1(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::Page1)
  7. {
  8. ui->setupUi(this);
  9. }
  10.  
  11. Page1::~Page1()
  12. {
  13. delete ui;
  14. }
  15.  
  16. void Page1::on_pushButton_clicked()
  17. {
  18. Page2 *form = new Page2();
  19. QString testo;
  20. testo=ui->to_pass->text();
  21. emit(transfer(testo));
  22. connect(this, SIGNAL(trasfer(QString)), form, SLOT(UpdateField(QString)));
  23. form->show();
  24. }
To copy to clipboard, switch view to plain text mode 

Page2.h:
Qt Code:
  1. #ifndef PAGE2_H
  2. #define PAGE2_H
  3.  
  4. #include <QWidget>
  5.  
  6. namespace Ui {
  7. class Page2;
  8. }
  9.  
  10. class Page2 : public QWidget
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit Page2(QWidget *parent = 0);
  16. ~Page2();
  17.  
  18. private slots:
  19. void UpdateField(QString text);
  20.  
  21. private:
  22. Ui::Page2 *ui;
  23. };
  24.  
  25. #endif // PAGE2_H
To copy to clipboard, switch view to plain text mode 

Page2.cpp:

Qt Code:
  1. #include "page2.h"
  2. #include "ui_page2.h"
  3.  
  4. Page2::Page2(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::Page2)
  7. {
  8. ui->setupUi(this);
  9. }
  10.  
  11. Page2::~Page2()
  12. {
  13. delete ui;
  14. }
  15.  
  16. void Page2::UpdateField(QString text)
  17. {
  18. ui->receive->clear();
  19. ui->receive->setText(text);
  20. }
To copy to clipboard, switch view to plain text mode 

Thanks for any suggestion!