Hello.
I'm currently learning how to program in c++ with qt and I'm having a problem when trying to emit a signal to a second mainwindow.
The whole idea is to emit a signal inside a function in the first form and catch it in the second form to add a line to a textEdit.
The idea is to use the second form as some type of debug console, there i want to show debuggin messages so to avoid having a system console open to show the qDebug messages and to provide a save and report mechanism to the messages.

I wrote this simple example to demostrate my problem.

main.cpp
Qt Code:
  1. #include <QtGui>
  2. #include "first.h"
  3. #include "second.h"
  4.  
  5. int main(int argc, char** argv)
  6. {
  7. QApplication app(argc, argv);
  8.  
  9. first f;
  10. f.show();
  11.  
  12. second s;
  13. s.show();
  14.  
  15. return app.exec();
  16. }
To copy to clipboard, switch view to plain text mode 

first.cpp
Qt Code:
  1. #include <QtGui>
  2.  
  3. #include "first.h"
  4. #include "second.h"
  5.  
  6. first::first()
  7. {
  8.  
  9. QPushButton *button = new QPushButton("First", this);
  10. setCentralWidget( button );
  11.  
  12.  
  13. QString text = "test";
  14. connect( button, SIGNAL ( clicked() ) ,this, SLOT( doemit() ));
  15.  
  16. //if i uncomment the next two lines the program stales and never shows the forms
  17. //second s;
  18. //connect( this, SIGNAL(MySignal(QString)), &s, SLOT( add() ));
  19.  
  20. }
  21.  
  22. first::~first()
  23. {}
  24.  
  25. void first::doemit() {
  26.  
  27. qDebug() << "doemit called";
  28.  
  29. QString test = "text";
  30. emit MySignal(test);
  31.  
  32. }
  33.  
  34. #include "first.moc"
To copy to clipboard, switch view to plain text mode 

first.h
Qt Code:
  1. #ifndef first_H
  2. #define first_H
  3.  
  4. #include <QtGui/QMainWindow>
  5.  
  6. class first : public QMainWindow
  7. {
  8. Q_OBJECT
  9. public:
  10. first();
  11. virtual ~first();
  12.  
  13. public slots:
  14. void doemit();
  15.  
  16. signals:
  17. void MySignal( QString );
  18. };
  19.  
  20. #endif // first_H
To copy to clipboard, switch view to plain text mode 

second.cpp
Qt Code:
  1. #include "second.h"
  2. #include "first.h"
  3.  
  4. #include <QtGui>
  5. #include <QTextEdit>
  6.  
  7. second::second() {
  8.  
  9. textEdit = new QTextEdit;
  10. setCentralWidget(textEdit);
  11.  
  12. first f;
  13. connect(&f, SIGNAL(MySignal(QString)), this, SLOT(add()));
  14. }
  15.  
  16. second::~second(){}
  17.  
  18. void second::add(){
  19. qDebug() << "Slot Called";
  20. textEdit->append ( "Blah" );
  21. }
  22.  
  23. #include "second.moc"
To copy to clipboard, switch view to plain text mode 

second.h
Qt Code:
  1. #ifndef second_H
  2. #define second_H
  3.  
  4. #include <QtGui>
  5. #include <QTextEdit>
  6.  
  7. class second : public QMainWindow
  8. {
  9. Q_OBJECT
  10. public:
  11. second();
  12. virtual ~second();
  13. QTextEdit *textEdit;
  14.  
  15. public slots:
  16. void add();
  17. };
  18.  
  19. #endif // second_H
To copy to clipboard, switch view to plain text mode 

What happens with the program is that doemit() is called in first.cpp but never reaches the slot in second.cpp.
if i try to reverse the connection, as in commenting the connect line in second.cpp and uncommenting the connect in first the same happens
but if i leave both connects the program starts but nothing is show in screen.

Maybe i can't have to mainwindows as one blocks the other and i need to dig into threading, but i would like to avoid that.

I hope that my problem is clear, as I'm not a native english speaker maybe my writing is a little cryptic at best.