[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);

}





留言

這個網誌中的熱門文章

[TensorFlow, C++, Visual Studio, Windows] TensorFlow C++ 如何編譯與解決BUG (How to build Tensorflow C++ API with Visual Studio and solve BUG)

[Ubuntu, Docker, Docker Swarm] Docker Swarm 建置 Jupyter Notebook 流程

[Docker Swarm] Docker Swarm 指令