As I understand the problem is that the content of the user class is transmitted through the signal. Using Q_DECLARE_METATYPE in the class prototype produced an error. How do I transfer the data in this case?

error: no matching function for call to 'MainWindow::setMail(SetMail*&)' emit this->setMail(set); // настроить письмо ^ class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); signals: void setMail(SetMail); }; void MainWindow::on_pushButtonStart_clicked() { SetMail *set = new SetMail(this); set->provider = prov->nowProvider(); set->sender = ""; emit this->setMail(set); } int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); TransportMail *tm = new TransportMail(); QObject::connect(&w, SIGNAL(setMail(SetMail)), tm, SLOT(setMail(SetMail))); } 

    1 answer 1

    In the announcement of the signal object is transmitted:

     signals: void setMail(SetMail); 

    And when you try to transfer, you try to pass a pointer:

     SetMail *set = new SetMail(this); ... emit this->setMail(set); 

    Need to fix the ad signal on

     signals: void setMail(SetMail *); 

    And do not forget to fix the receiving slot