......signals: void signal_connect(QHostAddress host, int port);.....
.....void ImitMainWindow::on_btnConnectClicked(QHostAddress host, int port){ _host = host; _port = port; qDebug() << "ImitMainWindow::on_btnConnectClicked()"; emit signal_connect(_host, _port);}......
....public slots: void imitatorconnect(QHostAddress host, int port);private: QHostAddress _host; int _port; ImitMainWindow *imitatorWindow;
....imitatorWindow = new ImitMainWindow(); connect(imitatorWindow,SIGNAL(signal_connect(QHostAddress,int)),this,SLOT(imitatorconnect(QHostAddress,int)));......void Imitator::imitatorconnect(QHostAddress host, int port){ qDebug() << "Imitator::imitatorconnect"; }
#ifndef IMITATOR_H#define IMITATOR_H#include "imitmainwindow.h"#include <QObject>class Imitator : public QObject{ Q_OBJECTpublic: explicit Imitator(QObject *parent = 0);public slots: void imitatorconnect(QHostAddress host, int port); signals: private: QHostAddress _host; int _port; bool imitatorConnected; ImitMainWindow *imitatorWindow;};#endif // SEACARGOIMITATOR_H
#include "imitator.h"Imitator::SeaCargoImitator(QObject *parent) : QObject(parent){ imitatorWindow = new ImitMainWindow(); connect(imitatorWindow,SIGNAL(signal_connect(QHostAddress,int)),this,SLOT(imitatorconnect(QHostAddress,int)));}void Imitator::imitatorconnect(QHostAddress host, int port){ qDebug() << "SeaCargoImitator::imitatorconnect"; }}
#ifndef IMITMAINWINDOW_H#define IMITMAINWINDOW_H#include <QMainWindow>namespace Ui {class ImitMainWindow;}class ImitMainWindow : public QMainWindow{ Q_OBJECT public: explicit ImitMainWindow(QWidget *parent = 0); ~ImitMainWindow();public slots: void on_btnConnectClicked(QHostAddress host, int port);signals: void signal_connect(QHostAddress host, int port); private: Ui::ImitMainWindow *ui; QHostAddress _host; int _port;};
#include "imitmainwindow.h"#include "ui_imitmainwindow.h"inline QString rus(const char* str){ return (QApplication::translate(0,str,0,QApplication::UnicodeUTF8));}ImitMainWindow::ImitMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::ImitMainWindow){ ui->setupUi(this);}ImitMainWindow::~ImitMainWindow(){ delete ui;}void ImitMainWindow::on_btnConnectClicked(QHostAddress host, int port){ _host = host; _port = port; qDebug() << "ImitMainWindow::on_btnConnectClicked()" << _host << _port; emit signal_connect(_host, _port);}#endif // IMITMAINWINDOW_H