我一般习惯这样写
pro中
CONFIG(release, debug|release){
CONFIG += static
}
static{
DEFINES += QT_PLUGIN_STATIC_LINK
QTPLUGIN += qsqlodbc
QTPLUGIN += qsqlite
}
在main.cpp中
#ifdef QT_PLUGIN_STATIC_LINK
#include<QtPlugin>
Q_IMPORT_PLUGIN(QSQLiteDriverPlugin)
Q_IMPORT_PLUGIN(QODBCDriverPlugin)
#endif