When should Q_OBJECT be used?

前端 未结 4 2324
名媛妹妹
名媛妹妹 2020-11-27 16:51

The documentation states that:

The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and sl

4条回答
  •  心在旅途
    2020-11-27 17:35

    What @liaK said is correct (in short: you should always use the Q_OBJECT macro in any class that derives from QObject).

    One thing that I haven't seen highlighted is that if you don't explicitly put the Q_OBJECT macro then using the sometimes very handy qobject_cast won't work!!!

提交回复
热议问题