PDA

View Full Version : QtcoSocket -QtNetwork Compile error



Daxos
13th July 2010, 15:18
Hi,
I have this kind of problem:

I have two class and both are subclass of qObject.
The first include onlly my personale include, the second class include QTcpServer and include Qt networnk (#include <QtNetwork>).

I want to be able to include the first class in the second class but I have this error:

: #error : qfile.h must be included before any header file that defines open

How i can solveed it?

Bye, Darui

wysota
13th July 2010, 15:42
Change the order of includes.

Daxos
13th July 2010, 15:49
If I change the order of include I have this error:

: error C2039: '_write' : is not a member of 'QTcpSocket'

wysota
13th July 2010, 16:24
Please show us your includes.

Daxos
14th July 2010, 09:39
Ok,
this is a piece of my first header:



A.h

#ifndef A_H
#define A_H

#include <QTcpServer>
#include <QTcpSocket>
class B;

class A: public QObject
{
.. .. ..
};
#endif



and the implementation is:


A.cpp
#include "A.h"
#include <QtNetwork>

#include "B.h"

..
..
..



Where B is:



B.h
#ifndef B
#define B

#include "HostInfo.h"

class B : public QObject
{
Q_OBJECT



the implementation is


#include "B.h"

..
..
..



while the class HostInfo is:



#ifndef HOSTINFO_H
#define HOSTINFO_H

#include "QTcpSocket"

typedef struct Host{
QTcpSocket* pxSocket;
}HostInfo;

#endif



Thanks

wysota
14th July 2010, 09:49
Is it possible for you to prepare a minimal compilable example reproducing the problem?

Also: which exactly include line does the error refer to?

Daxos
15th July 2010, 09:23
I have solved my problem.

The problem is another propretary librabry that doesn't support Qt.
I have solved whit another design for my application.

Thanks and sorry if this is only my personal error.

Bye, Dax