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.
39 lines
726 B
C++
39 lines
726 B
C++
#ifndef SAVEIMGTHREAD_H
|
|
#define SAVEIMGTHREAD_H
|
|
|
|
#include <QThread>
|
|
#include "QPixmap"
|
|
#include "QDir"
|
|
|
|
class SaveImgThread : public QThread
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SaveImgThread(QObject *parent = 0){};
|
|
~SaveImgThread(){};
|
|
void setPixmap(const QPixmap& m_pix,const QString filepath,const QString filename){
|
|
m_pixmap = m_pix;
|
|
m_path = filepath;
|
|
m_filename = filename;
|
|
|
|
}
|
|
void run() Q_DECL_OVERRIDE{
|
|
QDir m_dir;
|
|
bool bflag = m_dir.exists(m_path);
|
|
if (!bflag)
|
|
m_dir.mkpath(m_path);
|
|
QString m_savefile = m_path + m_filename;
|
|
m_pixmap.save(m_savefile);
|
|
emit(resultReady());
|
|
};
|
|
private:
|
|
QPixmap m_pixmap;
|
|
QString m_path;
|
|
QString m_filename;
|
|
signals :
|
|
void resultReady();
|
|
};
|
|
|
|
#endif // SAVEIMGTHREAD_H
|