#ifndef TWO_H#define TWO_H#include <QtCore>class two{public: two();signals: void mySignal(); // сигнал};#endif // TWO_H
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QtCore>#include "two.h"namespace Ui {class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui;public slots: void mySlot(); // слот};#endif // MAINWINDOW_H
#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); two *t =new two(); QObject::connect(t,SIGNAL(mySignal()),this, SLOT(mySlot())); // ошибка здесь}MainWindow::~MainWindow(){ delete ui;}void MainWindow::mySlot(){}
class two : public QObject{Q_OBJECTpublic: two();signals: void mySignal(); // сигнал};