C++ Qt signal and slot not firing

前端 未结 3 1618
慢半拍i
慢半拍i 2020-11-27 08:23

I am having difficulty in my Qt program with connecting button signals to my slots. My code is:

Main.cpp

#include 
#include         


        
3条回答
  •  遥遥无期
    2020-11-27 09:00

    Add Q_OBJECT to your class, like this:

    class MainWidget : public QWidget
    {
        Q_OBJECT
    

    You also have to run moc to generate some helper code. qmake does that automatically for your, but if you compile this yourself, you need to run moc.

提交回复
热议问题