sbtree我和你想的一样,主要是我想在Thread ::run()调用received_msg这个QTextedit类的方法,我是这么用的esp->received_msg->append(),make后出错:
invalid use of undefined type struct QTextEdit,
forward declaration of struct QTextEdit;刚开始学QT三周,在linux下做,我贴一下源码
看看有什么错误。
Thread.h
#ifndef THREAD_H
#define THREAD_H
#include<QThread>
class Thread : public QThread
{
Q_OBJECT
public:
Thread();
protected:
void run();
};
#endif
Thread.cpp
#include <QtCore>
#include "Thread.h"
#include "QespTest.h"
Thread ::Thread()
{
}
void Thread::run()
{
QespTest *esp =new QespTest();
char buff[1024];
int numBytes;
do
{
numBytes=esp->port->bytesAvailable();
if(numBytes>0)
{
if(numBytes>1024) numBytes=1024;
int i=esp->port->read(buff,numBytes);
buff
='\0';
QString msg =buff;
esp->received_msg->append(msg);
esp->received_msg->ensureCursorVisible();
}
}while(numBytes>0);
}
QespTest.h
#ifndef _QESPTEST_H_
#define _QESPTEST_H_
#include <QWidget>
#include <QextSerialPort>
class QLineEdit;
class QTextEdit;
class QextSerialPort;
class QSpinBox;
class QespTest : public QWidget
{
Q_OBJECT
public:
QespTest(QWidget *parent=0);
virtual ~QespTest();
QTextEdit *received_msg;
QextSerialPort *port;
public slots:
void serialOperate();
private slots:
void closePort();
void openPort();
};
#endif
我感觉错误就是引用时候的错,但是不知道该怎么写。。。?[ 此帖被stone123在2009-07-24 09:45重新编辑 ]