Home > front end >  QObject::connect: No such slot QMainWindow::On_clicked_delCare() in ../Gestion_parc_auto/choice_page
QObject::connect: No such slot QMainWindow::On_clicked_delCare() in ../Gestion_parc_auto/choice_page

Time:01-31

oplease, help me to solve this probleme. I don't know the proble but if I put QObject in file.h he generate error !

file.h

#include <QMainWindow>
class choice_page_2 : public QMainWindow
{
public:
    choice_page_2();
    QWidget* M_Widget = new QWidget();

public slots:
    
    void On_clicked_delCare();
   
};

#endif // CHOICE_PAGE_2_H

fill.cpp

    choice_page_2::choice_page_2()
{QPushButton *ManageBtn = new QPushButton(tr("Gérer une voiture"));
       QMenu *menu = new QMenu(this);
       QAction* AddCare = new QAction(tr("Ajouter une voiture"), this);
       QAction* DelCare = new QAction(tr("Supprimer une voiture"), this);
      
    QObject::connect( DelCare, SIGNAL(triggered()),this, SLOT(On_clicked_delCare()));
}

I get this error: **QObject::connect: No such slot QMainWindow::On_clicked_delCare()

CodePudding user response:

All classes that contain signals or slots must mention Q_OBJECT at the top of their declaration.

CodePudding user response:

Thank you, but if a put Q_Object to top of declaration, I get many other

 erreur : undefined reference to `vtable for choice_page_2' 

/ erreur : undefined reference to `choice_page_2::staticMetaObject'

:-1: erreur : choice_page_2.o: in function `choice_page_2::tr(char const*, char const*, int)':
  •  Tags:  
  • Related