[Qt-interest] Extract used Qt classes from sources
Srdjan Todorovic
todorovic.s at googlemail.com
Fri Oct 9 12:00:09 CEST 2009
Hi,
On 09/10/2009, Antonio Di Monaco <tony at becrux.com> wrote:
> In my project I've used the global header files (QtGui, QtCore,
> QtNetwork, ...), without caring about the Qt classes I really need, in
> order to speed up the editing of my source files. Now that my project is
> working, I'd like to find out, for each .h/.cpp, which Qt classes I really
> use, and to replace the global #include directives with specialized ones,
> in order to speed up compilation. Of course, I was wondering if there's a
> command-line tool that can do this job.
I don't know of a tool to do automated header tidying-up. If you don't
have too many files, you could do the process manually.
Assuming you have a class that uses: QList, QProcess and QTcpSocket;
you could comment out the global header includes and recompile.
This would be LeaningOnTheCompiler and will show you that various
classes are undeclared. All you have to do is to just add includes for
the classes that are undefined, repetitively until you no longer have
compiler errors.
The only problem is that it could be quite time consuming.
eg.
//#include <QtCore>
int main()
{
QString string = "foo";
return 0;
}
gives you: tester.cpp:5: error: ‘QString’ was not declared in this scope
So just add and include for QString.
Hope that helps.
Srdjan
More information about the Qt-interest-old
mailing list