Con NÃt
25th January 2011, 12:41
i made a new class inheriting QTcpsocket,with the following content :
mytcpsocket.h
#ifndef MYTCPSOCKET_H
#define MYTCPSOCKET_H
#include <QTcpSocket>
#include <QString>
#include <qvariant.h>
class MyTcpSocket : public QTcpSocket
{
public:
MyTcpSocket(QObject* parent = 0);
void setClientUser(const QString &strClientUser);
void setGroup(const int &iGroup);
QString getClientUser();
int getGroup();
private:
QString strClientUser;
int iGroup;
};
#endif // MYTCPSOCKET_H
mytcpsocket.cpp
#include "mytcpsocket.h"
MyTcpSocket::MyTcpSocket(QObject* parent) : QTcpSocket(parent)
{
//strClientUser = tr("Student");
iGroup = 0;
}
void MyTcpSocket::setClientUser(const QString &strClientUser){
this->strClientUser = strClientUser;
}
void MyTcpSocket::setGroup(const int &iGroup){
this->iGroup = iGroup;
}
QString MyTcpSocket::getClientUser(){
return strClientUser;
}
int MyTcpSocket::getGroup(){
return iGroup;
}
whenever i used the method of setClientUser or getClientUser
the program got exited with code -1073741819
but the methods of setGroup and getGroup run properly.
help me get to know and solve this problem.thank you so much
mytcpsocket.h
#ifndef MYTCPSOCKET_H
#define MYTCPSOCKET_H
#include <QTcpSocket>
#include <QString>
#include <qvariant.h>
class MyTcpSocket : public QTcpSocket
{
public:
MyTcpSocket(QObject* parent = 0);
void setClientUser(const QString &strClientUser);
void setGroup(const int &iGroup);
QString getClientUser();
int getGroup();
private:
QString strClientUser;
int iGroup;
};
#endif // MYTCPSOCKET_H
mytcpsocket.cpp
#include "mytcpsocket.h"
MyTcpSocket::MyTcpSocket(QObject* parent) : QTcpSocket(parent)
{
//strClientUser = tr("Student");
iGroup = 0;
}
void MyTcpSocket::setClientUser(const QString &strClientUser){
this->strClientUser = strClientUser;
}
void MyTcpSocket::setGroup(const int &iGroup){
this->iGroup = iGroup;
}
QString MyTcpSocket::getClientUser(){
return strClientUser;
}
int MyTcpSocket::getGroup(){
return iGroup;
}
whenever i used the method of setClientUser or getClientUser
the program got exited with code -1073741819
but the methods of setGroup and getGroup run properly.
help me get to know and solve this problem.thank you so much