出错求解
错误信息error: new types may not be defined in a return type
源代码.h文件
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include<QThread>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
class MyThread:public QThread
{
public:
virtual void run();
}
#endif // MAINWINDOW_H
.cPP 文件
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QThread>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MyThread a;
MyThread b;
a.start();
b.start();
a.wait();
b.wait();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MyThread::run()
{
for(int count=0;count<20;count++)
{
sleep(1);
qDeug("ping!");
}
}
[解决办法]
class MyThread:public QThread
{
public:
virtual void run();
}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;
少了个分号
[解决办法]
.h最后分号结尾
这种编辑错误IDE就会提示你的,LZ不用Qt-creator吗