//头文件
#include <QtWidgets/QApplication>
#include <QThread>
#include"tests.h"
static tests* W = NULL;
class WThread :public QThread
{
public:
void run()
{
msleep(3000);
W->Hide();
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
W = new tests();
W->show();
WThread wt;
wt.start();
return a.exec();
}
tests.h文件
#pragma once
#include<qwidget.h>
class tests :public QWidget
{
Q_OBJECT
public:
tests();
virtual ~tests();
signals:
void Hide();
};
tests.cpp文件
#include "tests.h"
tests::tests()
{
connect(this,SIGNAL(Hide()), this,SLOT(hide()));
}
tests::~tests()
{
}