qtgui.h
#ifndef QTGUI_H
#define QTGUI_H
#pragma once
#include <QObject>
#include<qthread.h>
#include<thread>
#include "prasejson.h"
using namespace std;
class QTgui :public QThread
{
Q_OBJECT
signals :
void sigCurrentImage2(QList<float> img);
public:
QTgui(QObject *parent);
~QTgui();
int k;
int add;
int timee=3;
std::thread * tthread;
QString a;
QString b;
void run();
void addd();
void porcess();
void initgui(QString a,QString b);
PraseJson *peasejson;
};
#endif // QTGUI_H
qtgui.cpp
#include "qtgui.h"
#include <QString>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QFile>
#include <QJsonObject>
#include <QDebug>
#include <QJsonArray>
#include "sqlopen.h"
#include "prasejson.h"
#include <QMessageBox>
#include <QSqlQuery>
#include <QJsonDocument>
QTgui::QTgui(QObject *parent)
: QThread(parent)
{
}
QTgui::~QTgui()
{
}
void QTgui::run()
{
// 使用QSqlQuery查询整张表
QSqlQuery query;
query.exec("select * from student4");
QList<float> intList;
float max = 0;
float min = 0;
while(query.next())
{
if((this->a) == query.value(1).toString()){
QJsonObject qson = peasejson->praseVarious(query.value(5).toString());
intList.append(qson.value(this->b).toString().toFloat());
}
}
emit sigCurrentImage2(intList);
}
void QTgui::addd()
{
start();
}
void QTgui::initgui(QString a,QString b)
{
this->a = a;
this->b = b;
}
void QTgui::porcess()
{
}
主函数
public:
QTgui* g1;
QTgui* g2;
qtgui1 * g3;
qtgui2 * g4;
QString iutem;
private:
private slots:
void slot2(QStandardItemModel* );
void slot1(QStandardItemModel* );
void slot3(QList<float> intList);
g1 = new QTgui(this);
connect(g1, SIGNAL(sigCurrentImage2(QList<float>)), this, SLOT(slot3(QList<float>)));
g3 = new qtgui1(this);
connect(g3, SIGNAL(asd(QStandardItemModel*)), this, SLOT(slot1(QStandardItemModel*)));
g4 = new qtgui2(this);
connect(g4, SIGNAL(asd(QStandardItemModel*)), this, SLOT(slot2(QStandardItemModel*)));