析构QThread线程退出的问题
parent
8d72bf5f42
commit
7fe003ebd0
25
Qss.cpp
25
Qss.cpp
|
@ -22,7 +22,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
|
||||||
#define QSSDIALOG_SHADOW_WIDTH 12
|
#define QSSDIALOG_SHADOW_WIDTH 12
|
||||||
#define QSSDIALOG_BODER_WIDTH 0
|
#define QSSDIALOG_BODER_WIDTH 0
|
||||||
|
@ -284,6 +284,16 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* =
|
||||||
QString css = in.readAll();
|
QString css = in.readAll();
|
||||||
qDebug()<<css;
|
qDebug()<<css;
|
||||||
m_frame->setStyleSheet(css);
|
m_frame->setStyleSheet(css);
|
||||||
|
|
||||||
|
|
||||||
|
// QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(m_frame);
|
||||||
|
// shadow_effect->setOffset(0, 0);
|
||||||
|
// //阴影颜色
|
||||||
|
// shadow_effect->setColor(QColor(38, 78, 119, 127));
|
||||||
|
// //阴影半径
|
||||||
|
// shadow_effect->setBlurRadius(15);
|
||||||
|
// m_frame->setGraphicsEffect(shadow_effect);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1716,19 +1726,18 @@ void QssMaskWidget::paintEvent(QPaintEvent *event)
|
||||||
QWidget::paintEvent(event);
|
QWidget::paintEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSSASyncFunction::QSSASyncFunction(QWidget *parent)
|
QSSASyncProcess::QSSASyncProcess(QWidget *parent)
|
||||||
{
|
{
|
||||||
this->mParent = parent;
|
this->mParent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSSASyncFunction::~QSSASyncFunction()
|
QSSASyncProcess::~QSSASyncProcess()
|
||||||
{
|
{
|
||||||
this->mThread.exit(0);
|
this->mThread.exit(0);
|
||||||
this->mThread.deleteLater();
|
this->mThread.terminate();
|
||||||
this->mThread.wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSSASyncFunction::Start()
|
int QSSASyncProcess::Start()
|
||||||
{
|
{
|
||||||
this->moveToThread(&mThread);
|
this->moveToThread(&mThread);
|
||||||
connect(this, SIGNAL(StartRun()), this, SLOT(Run()));
|
connect(this, SIGNAL(StartRun()), this, SLOT(Run()));
|
||||||
|
@ -1739,8 +1748,8 @@ int QSSASyncFunction::Start()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSSASyncFunction::Run()
|
void QSSASyncProcess::Run()
|
||||||
{
|
{
|
||||||
|
qDebug()<<"test run";
|
||||||
emit(Done());
|
emit(Done());
|
||||||
}
|
}
|
||||||
|
|
10
Qss.h
10
Qss.h
|
@ -477,20 +477,20 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
// 异步执行任务,不会阻塞ui线程
|
// 异步执行任务,不会阻塞ui线程
|
||||||
class QSSASyncFunction : public QObject{
|
class QSSASyncProcess : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSSASyncFunction(QWidget *parent = nullptr);
|
QSSASyncProcess(QWidget *parent = nullptr);
|
||||||
~QSSASyncFunction();
|
~QSSASyncProcess();
|
||||||
int Start();
|
int Start();
|
||||||
signals:
|
signals:
|
||||||
void DonePercent(int);
|
void DonePercent(int);
|
||||||
void Done();
|
void Done();
|
||||||
void StartRun();
|
void StartRun();
|
||||||
protected:
|
protected slots:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
|
protected:
|
||||||
QWidget *mParent;
|
QWidget *mParent;
|
||||||
QThread mThread;
|
QThread mThread;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue