You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
#ifndef CHECKTHREAD_H
|
|
#define CHECKTHREAD_H
|
|
|
|
#include <QThread>
|
|
#include "QSqlQuery"
|
|
#include "databasesql.h"
|
|
#include "QMetaType"
|
|
#include "QStandardItemModel"
|
|
#include <QSqlRecord>
|
|
class CheckThread : public QThread
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CheckThread(QObject *parent){ bFlags = false; };
|
|
~CheckThread(){};
|
|
void setModelFlags(bool m_flags = false){ bFlags = m_flags; }
|
|
void setCheckStr(DataBaseSql *pDb ,QString m_str){
|
|
m_pDb = pDb;
|
|
m_CheckStr = m_str;
|
|
};
|
|
void run() Q_DECL_OVERRIDE{
|
|
QSqlQuery sql;
|
|
int nCount = 0;
|
|
if (m_pDb){
|
|
|
|
m_pDb->checkoutData(m_CheckStr, sql);
|
|
|
|
if (bFlags == true)
|
|
{
|
|
while (sql.next())
|
|
{
|
|
QSqlRecord record = sql.record();
|
|
QString fieldName = record.fieldName(0);
|
|
QString num = sql.value(0).toString();
|
|
nCount = num.toInt();
|
|
// /*这里下面是统计查询到的通道对应的产品总数*/
|
|
}
|
|
}
|
|
}
|
|
emit (resultReady(sql));
|
|
emit(resultCount(nCount));
|
|
}
|
|
private:
|
|
DataBaseSql *m_pDb;
|
|
QString m_CheckStr;
|
|
bool bFlags;
|
|
signals:
|
|
void resultReady(QSqlQuery sql);
|
|
void resultCount(int nCount);
|
|
};
|
|
|
|
#endif // CHECKTHREAD_H
|