Important: Please read the Qt Code of Conduct -

SIGNAL / SLOT problem between 2 classes

  • Hello all :)

    I have 2 ui classes into an "Application" class

    class Application
    			Application(QString name, QString version);
    			void run();
    			QString name_;
    			QString version_;
    			/********* UI ********/
    			Menu_ui menu_;
    			Employee_sheet_ui employee_sheet_;

    I want to show "employee_sheet_ when I press a button from "menu_"
    ATM, I thought it was necessary to do like that:

    void Application::run()
    	QObject::connect(menu_.ui.pushButton, SIGNAL(clicked()), &employee_sheet_, SLOT(;

    ...but it doesn't work

    Someone can explain me my error please?

    Thanks a lot in advance :)

    For information, my Enployee_sheet class:

    #include <QWidget>
    #include "ui_employee_sheet_ui.h"
    class Employee_sheet_ui : public QWidget
    	Employee_sheet_ui(QWidget *parent = Q_NULLPTR);
    	Ui::Employee_sheet_ui ui;

  • @Groot said in SIGNAL / SLOT problem between 2 classes:

    Someone can explain me my error please?

    Your connect() is wrong => please take time to read documentation:
    And prefere using new connect syntax so you will get connection error at compilation time.

  • I have understand! i'm stupid! (thx Lelev)

    I must remplace:

    QObject::connect(menu_.ui.pushButton, SIGNAL(clicked()), &employee_sheet_, SLOT(;


    	QObject::connect(menu_.ui.pushButton, SIGNAL(clicked()), &employee_sheet_, SLOT(show()));

  • @Groot
    Yes, but as @KroMignon said it would be even better if you decided to change over to:

    QObject::connect(menu_.ui.pushButton, &QPushButton::clicked, &employee_sheet_, &EmployeeSheet::show);


  • Ok! thanks for you help guys :)

Log in to reply