zl程序教程

您现在的位置是:首页 >  工具

当前栏目

QT+SQLite 判断表中是否含有指定字段

QtSQLite 判断 是否 指定 表中 含有
2023-09-11 14:16:45 时间
  1. // 判断表 CaseHistory 中是否有字段 SuccessRate

  2. QString strSql = QString::fromLocal8Bit("select * from sqlite_master where name='CaseHistory' and sql like '%SuccessRate%'");

  3. QSqlQuery query;

  4. query.exec(strSql);

  5. if (!query.next())

  6. { // 无SuccessRate字段

  7. // TODO:

  8. }

QT判断是否含有某字符串

#include<QString>
 
  1. QString strl="iloveyou";

  2. str.contains("you",Qt::CaseSensitive);//成功返回true 第二个参数表示是否大小写敏感