[Qt, C++] Qt Timer 用法

	
#include <QtWidgets/QmainWIndow>

#include <QObject>

#include <QDebug>

#include <QtCore>

#include <QThread>



class A : public QObject

{

    Q_OBJECT

public:

    GUI *gui;

public slots:

    void GetTest1();

signals:

    void test1();

}

void GetTest1()

{

std::cout << "test1" << std::endl;

Sleep(10);

}

A *testA;

QThread *threadA;

int main()

{

testA = new A();

testA->moveToThread(threadA);

threadA->start();

Qtimer *timer = new Qtimer(this);

connect(timer, SIGNAL(timeout()), testA, SLOT(GetTest1()));

timer->start(1000);

}





留言

這個網誌中的熱門文章

[CentOS, OpenCV] CentOS 7 安裝 OpenCV 3.4.5 (CentOS install OpenCV )

[CGAL, BOOST, C++, Visual Studio] Mutex is not supported when compiling with /clr or clr:pure