我创造了一个线程类
如下
#ifndef THREAD1_H_
#define THREAD1_H_
#include <iostream>
using namespace std;
class thread1:public QThread
{
Q_OBJECT
public:
thread1();
protected:
void run();
};
#endif
#include "thread1.h"
#include "windows.h"
thread1::thread1()
{}
// place your code here
void thread1::run()
{
QString text="A";
while(true)
{
cout << qPrintable(text);
Sleep(1);
}
}
当我调用的时候 创建一个thread1的对象
thread1 t1;t1.start();之后出现了内存错误
当我这样创建的时候没有错误,请问这是为什么
thread1 *t1=new thread1();
t1->start();
第一种方法是在C++ GUI Programming with Qt4 Book 例程中看到的 不知道他的为什么就好用
请各位前辈点拨