当前位置: 代码迷 >> QT开发 >> 看上去像函数定义,但没有参数列表;跳过明显的函数体
  详细解决方案

看上去像函数定义,但没有参数列表;跳过明显的函数体

热度:50   发布时间:2016-04-25 03:51:00.0
看起来像函数定义,但没有参数列表;跳过明显的函数体?
//tcpserver.h

#ifndef TCPSERVER_H
#define TCPSERVER_H
#include "tcpthread.h"
#include <QTcpServer>

class tcpserver : public QTcpServer
{
    Q_OBJECT
public:
    explicit tcpserver(QObject *parent = 0);
    //QList<int> clientDescriptorList;

signals:
    void newRow(int);
    void displayInfo(int,QString, int);
    void updateBar(int, qint64);
    void signal_send_command(int,int);

public slots:
    void incomingConnection(int socketDescriptor);
    void slot_send_command(int,int);

};
#endif

//tcpserver.cpp

#include "tcpserver.h"


//构造函数
tcpserver::tcpserver(QObject *parent):
    QTcpServer(parent)
{
}

//重新定义了incomingConnection这个虚函数,
//开辟一个新的tcpsocket线程,从TcpServer获得socketDescriptor,
//并完成相应的信号连接

void tcpserver::incomingConnection(int socketDescriptor)
{
        qDebug() <<socketDescriptor;
        //clientDescriptorList.append(socketDescriptor);
        emit newRow(socketDescriptor); //display new client
        connect(this,SIGNAL(signal_send_command(int ,int)),this,SLOT(slot_send_command(int ,int)));
}

void tcpserver::slot_send_command(int sockDescriptor, int cmd)
{
    TcpThread *thread = new TcpThread(sockDescriptor,cmd, this);
    thread->start();
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    connect(thread,SIGNAL(displayInfo(int,QString,int)),this,SIGNAL(displayInfo(int,QString,int)));
    connect(thread,SIGNAL(updateBar(int,qint64)),this,SIGNAL(updateBar(int,qint64)));
}









这是一位前辈的代码,我想用一下,但是不知道怎么回事,运行的时候总是报错:

//构造函数
tcpserver::tcpserver(QObject *parent):
    QTcpServer(parent)
{
}

就是上边的这报错:D:\QtSpace\server\tcpserver.cpp:8: 错误:C2470: “parent”: 看起来像函数定义,但没有参数列表;跳过明显的函数体

郁闷死了,不知道怎么回事啊!
大家帮我看一下啊,我第一次弄QT啊

------解决方案--------------------
#include <QtCore>
------解决方案--------------------
有可能是tcpserver::tcpserver(QObject *parent):
    QTcpServer((parent)
这里的括号检查下是不是英文的括号
  相关解决方案