Error:'emit' was not declared in this scope

Qt編譯時報錯:

error: ‘emit’ was not declared in this scope; did you mean ‘exit’?
  9 |     emit Button->clicked();
      |     ^~~~
      |     exit

這是因爲在pro工程文件中添加了:

CONFIG += no_keywords

解決該報錯,可以使用Q_EMIT 替換 emit

類似的,使用Q_SLOTS來替換slot


參考鏈接:
https://stackoverflow.com/questions/48609640/qt-compiler-error-emit-was-not-declared-in-this-scope?answertab=votes

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章