Qt Connecting SIGNAL and SLOT in object member of MainWindow

后端 未结 2 1297
一生所求
一生所求 2021-01-24 12:34

I have a class MyClass with:

  - private: 
      pushButton *button;
      void connectSignalAndSlot();
  - private slot: 
      void buttonAction();
         


        
2条回答
  •  遥遥无期
    2021-01-24 13:05

    You must have MyClass inherit from QObject AND add Q_OBJECT macro in your MyClass definition (header file) to have slots/signals work.

    class MyClass : public QObject
    {
         Q_OBJECT
    
    public:
         ....
    };
    

提交回复
热议问题