I subclassed QThread and it's run method like this:
mythread.h
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
#include <QString>
{
Q_OBJECT
public:
myThread();
void run();
private:
//...
};
#endif // MYTHREAD_H
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
#include <QString>
class myThread : public QThread
{
Q_OBJECT
public:
myThread();
void run();
private:
//...
};
#endif // MYTHREAD_H
To copy to clipboard, switch view to plain text mode
mythread.cpp
#include "mythread.h"
#include <iostream>
myThread::myThread()
{
//...
}
void myThread::run()
{
for(int i=0; i<10; i++)
{
std::cout << i << std::endl;
}
}
#include "mythread.h"
#include <iostream>
myThread::myThread()
{
//...
}
void myThread::run()
{
for(int i=0; i<10; i++)
{
QThread::sleep(1);
std::cout << i << std::endl;
}
}
To copy to clipboard, switch view to plain text mode
How and when can i call this thread in order que keep the application responsive?
Sorry if it makes no sense ... my first thread experience
Bookmarks