诸如'XXX' was not declared in this scope, undefined reference to `XXX'解决办法

时间:2021-10-17 08:24:58

错误:'QSqlTableModel' was not declared in this scope

加入头文件

  
 
 #include<QtSql/QSqlTableModel>
  
 
 

即可。


错误:'QTableView' was not declared in this scope

加入头文件

  
 
 #include<QTableView>
  
 
 

即可。


此时又出现这样的错误

undefined reference to `QSqlDatabase::~QSqlDatabase()'

在.pro文件加入这句

  
 
 QT+=sql
  
 
 

即可。


本文出自 “大白菜” 博客,请务必保留此出处http://dreamylights.blog.51cto.com/1163218/1292304