当我重写QTableView时,出现以下问题:
/Users/lzm/Documents/QT/build-demo3-Desktop_Qt_5_15_2_clang_64bit-Debug/tableview.o:-1: error: Undefined symbols for architecture x86_64:
"vtable for TableView", referenced from:
TableView::TableView(QWidget*) in tableview.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
:-1: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [demo3.app/Contents/MacOS/demo3] Error 1
代码是这样的:
经过调试发现,但凡自定义控件需要用到信号和槽函数,就必须使用宏定义Q_OBJECT
具体使用则是在函数中加入: