C++ (Qt)void Form1::on_pushButton_clicked(){ emit needToChangeText(ui->lineEdit->text());}
C++ (Qt)void Form2::changeText(QString text){ ui->label->setText(text);}
C++ (Qt)#include <QtGui/QApplication>#include "Form1.h"#include "Form2.h" int main(int argc, char *argv[]){ QApplication a(argc, argv); Form1 f1; Form2 f2; QObject::connect(&f1, SIGNAL(needToChangeText(QString)), &f2, SLOT(changeText(QString))); f1.show(); f2.show(); return a.exec();}
class MainWindow : public QMainWindow{ Q_OBJECT // . . . signals : void needToChangeText(QString text);}