PDA

View Full Version : Qt modules in plain C++ project



Scope
13th November 2015, 21:18
Hi,

Whether can I use some modules of Qt in plain c++ project?
For example I would like to use the Xml and Network modules.

It is possible?
It can generate problems?

Regards,

d_stranz
13th November 2015, 23:01
The Qt XML module is marked as obsolete, so you should not use it in new projects. If you want plain old C++ support for XML, then you would be better off using xerces-c from the Apache project. (https://xerces.apache.org/xerces-c/). The new support for XML is in Qt Core, so you can't get around linking to that.

The Qt Network classes are for the most part derived from QObject, so you are tied to Qt Core there as well. Since they use signals and slots to communicate data and status, you'll need an event loop, which implies a QApplication class, so you end up with a Qt-based project, not a plain C++ one.

Scope
13th November 2015, 23:15
The Qt XML module is marked as obsolete, so you should not use it in new projects. If you want plain old C++ support for XML, then you would be better off using xerces-c from the Apache project.. The new support for XML is in Qt Core, so you can't get around linking to that.

Yes, it is marked obsolete but I find that reason why xml module is marked as obsolete is that "already work" see http://lists.qt-project.org/pipermail/interest/2013-August/008193.html


The Qt Network classes are for the most part derived from QObject, so you are tied to Qt Core there as well. Since they use signals and slots to communicate data and status, you'll need an event loop, which implies a QApplication class, so you end up with a Qt-based project, not a plain C++ one.
So, if I understand correctly Qt libraries can not be using with plain C++ project?

d_stranz
17th November 2015, 17:42
No, it is not marked obsolete because it "already works". It is marked obsolete because it has been replaced by QXmlStreamReader / Writer and it will no longer be maintained. This means that whatever bugs it has will not be fixed, and at some point it could be archived and removed from the Qt distribution.. The mailing list item you pointed to is irrelevant.

Qt *is* C++, of course. But like any library, you cannot use parts of it without linking to the library and distributing the DLLs with your application. Any part of Qt that uses QObject will require at least the QtCore library and usually more.

There are non-Qt options for XML (as I pointed out) and I am sure there are network packages as well, but in every case you will have to either build and link to a static library or distribute a shared library (DLL) with your app.

Scope
17th November 2015, 18:49
I know that when I use some xml classes from Qt then I must add at minimum core and xml dll but this is not a problem.

I want use Qt classes for xml because I already use them in another Qt project and I like them. Now I write plain C++ project and I want to use them.


What I found:
http://stackoverflow.com/questions/2720018/using-qts-xml-library-for-simple-operation

http://ubuntuforums.org/showthread.php?t=1452301&p=9112973#post9112973

It looks like we can use xml classes from Qt in plain c++ project without any problems.

Thanks,
Regards,