方法一:获取此表的数量,如果数量不为0则存在
QSqlQuery *m_pQuery = new QSqlQuery(m_msgdb);
if( m_pQuery->exec(QString("select count(*) from sqlite_master where type='table' and name='WarnMsg'"))) //关键的判断
{
m_pQuery->next();
int x = m_pQuery->value(0).toInt();
if( x == 0 )
{
QString strSql = QString::fromLocal8Bit("create table WarnMsg( 内容 varchar);");
if(!m_pQuery->exec( strSql ) )
{
QSqlError str = m_pQuery->lastError();