PDA

View Full Version : Reimplementing QFtp and "Cannot mix incompatible Qt libraries" error



ultr
20th March 2011, 13:46
I'm trying to reimplement QFtp class to add some methods I need to it.

Everything compiles and seems to work
but when I create a new instance of my QFtp in run-time
program exists with "Cannot mix incompatible Qt libraries" error.

I use sources of the very same version of Qt I have in my system.

Simple test code attached.

Thanks for help or any suggestions.

wysota
20th March 2011, 16:47
Did you rebuild all of Qt's libraries after changing the class? If not, did you at least rebuild the network library with the same options as the library contained in your system?

ultr
20th March 2011, 17:27
Thanks for you reply.

No, i haven't rebuilt the library.
I include the modified class in my source code (see attachment).
Why should I rebuild the whole Qt then?

wysota
20th March 2011, 17:33
No, i haven't rebuilt the library.
I include the modified class in my source code (see attachment).
So you have two classes called QFtp? How do you expect it to work? Why don't you subclass QFtp instead of changing the original class?

ultr
20th March 2011, 17:55
I have changed its name to UFtp and the results are the same. Test case in attachment.

I tried subclassing - it would be the best solution.
But the QTcpSocket I need access to is a private member of QFtpDTP, which can only be accessed with d_func().
See src/network/access/qftp.cpp

wysota
20th March 2011, 18:15
What do you need the socket for? You can probably access the socket using QObject::findChild().

ultr
20th March 2011, 18:39
> What do you need the socket for?
I need to limit its read buffer size.

> You can probably access the socket using QObject::findChild().
First I have to get to QFtpPrivate from the subclass. Private d_func() returns it.
But even if it make it protected/public I get an error when accessing it:

uftp.cpp: In member function ‘void UFtp::setReadBufferSize(qint64)’:
uftp.cpp:45:3: error: invalid use of incomplete type ‘struct QFtpPrivate’
/usr/include/qt4/QtNetwork/qftp.h:57:7: error: forward declaration of ‘struct QFtpPrivate’

wysota
20th March 2011, 22:07
> What do you need the socket for?
I need to limit its read buffer size.
I'm not sure doing it this way is a good idea. You could do it by implementing an artificial proxy and connect though that proxy.


> You can probably access the socket using QObject::findChild().
First I have to get to QFtpPrivate from the subclass.
No, you don't. Unless of course you want your app to magically stop working when Qt is upgraded. You need to find another way to do what you want.