Signal and slot working without Q_OBJECT Macro
-
Hi All,
class MainWindow : public QMainWindow { // Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; }; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(close())); }Q_OBJECT macro is commented, but still signal and slot is working fine.. Can someone please help me understand how this is possible ??
-
Hi All,
class MainWindow : public QMainWindow { // Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; }; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(close())); }Q_OBJECT macro is commented, but still signal and slot is working fine.. Can someone please help me understand how this is possible ??
Probably some prior generated files are still existing? It should stop working after you wiped the build folder and rebuild your program.
Regards
-
Probably some prior generated files are still existing? It should stop working after you wiped the build folder and rebuild your program.
Regards
@aha_1980 , Thanks for the confirmation
-
@aha_1980 , Thanks for the confirmation
So is you problem solved? Then please mark this topic as SOLVED too. Thanks!
-
Hi,
You are not adding any new signal or slot to your class but using what is already available hence there's no need for the Q_OBJECT macro in your case. However as soon as you want to implement signal/slot/property into your class you will have to add that macro.
-
Hi,
You are not adding any new signal or slot to your class but using what is already available hence there's no need for the Q_OBJECT macro in your case. However as soon as you want to implement signal/slot/property into your class you will have to add that macro.
-
Hi,
You are not adding any new signal or slot to your class but using what is already available hence there's no need for the Q_OBJECT macro in your case. However as soon as you want to implement signal/slot/property into your class you will have to add that macro.
@SGaist said in Signal and slot working without Q_OBJECT Macro:
You are not adding any new signal or slot to your class but using what is already available hence there's no need for the Q_OBJECT macro in your case. However as soon as you want to implement signal/slot/property into your class you will have to add that macro.
Also, without the
Q_OBJECTmacro,this->metaObject()->className()returns the wrong class.