我用单类继承的方式编得一个程序,源程序如下:
#include "hello.h"
#include <qlabel.h>
#include<qmultilineedit.h>
#include<qstring.h>
HelloForm::HelloForm( QWidget* parent, const char* name, WFlags fl):
HelloBaseForm(parent, name, fl)
{
}
HelloForm::~HelloForm()
{
}
void HelloForm::SayHello()
{
//system init!
if(fd!=0)
{
Txt_State->insertLine("serial port already open",-1);// line 26
}
isinit=0;
BInit=0;
initAT();
}
void HelloForm::GPRSOff()
{
MessageLabeloff->setText("GPRS is off!");
}
void HelloForm::quit_slot()
{
close();
}
void HelloForm::initAT()
{
if(isinit==0)//check if init
return;
if(fd==0)
{
if((fd=MySerial::open_port(fd,2))<0)
{
Txt_State->insertLine("open port error",-1);//line 52
return;
}
else
Txt_State->insertLine("open port success",-1);//line 56
if((fd=MySerial::set_opt(fd,9600,8,'N',1))<0)
{
Txt_State->insertLine("set port error",-1);// line 59
return;
}
else
Txt_State->insertLine("set port success",-1);// line 63
}
MySerial::nwrite(fd,"AT+CSCA?\r\n",sizeof("AT+CSCA?\r\n"));
BInit=1;
isinit=1;
}
编译出现如下错误:
g++ -c -I/armsys2410/qtx86/qtopia/include -I/armsys2410/qtx86/qt/include -pipe
-DQWS -fno-exceptions -fno-rtti -O2 -Wall -W -DNO_DEBUG -DQTOPIA_APP_INTERFACE -I.moc/linux-generic-g++/ -o .obj/linux-generic-g++//hello.o hello.cpp
hello.cpp: In member function `virtual void HelloForm::SayHello()':
hello.cpp:26: no matching function for call to `QLabel::insertLine(const
char[25], int)'
hello.cpp: In member function `void HelloForm::initAT()':
hello.cpp:52: no matching function for call to `QLabel::insertLine(const
char[16], int)'
hello.cpp:57: no matching function for call to `QLabel::insertLine(const
char[18], int)'
hello.cpp:61: no matching function for call to `QLabel::insertLine(const
char[15], int)'
hello.cpp:66: no matching function for call to `QLabel::insertLine(const
char[17], int)'
make: *** [.obj/linux-generic-g++//hello.o] Error 1
是什么原因?我认为insertLine(const QString * txt, int line)函数是QMultilineedit头文件中的,我已经包含进去了,为什么还会出现QLabel::insertLine(const char[17], int)'呢?
请高手帮忙,谢谢!