Hi Everyone,
I am currently including different Qt header files in my classes. But most of them can be replaced by QtGui. Is it a good way of doing that or should I just leave them as it is?
Thanks.
Chandan
Hi Everyone,
I am currently including different Qt header files in my classes. But most of them can be replaced by QtGui. Is it a good way of doing that or should I just leave them as it is?
Thanks.
Chandan
Well it is up to you. And in "normal" cases it not important. If you what to optimize size and speed of compilation use forward declarations where ever possible and use e.g.
chandan (1st March 2011)
Thanks for your help. Will this forward declaration will increase the time efficiency? I mean, currently I am writing an application which contains lots of customised widgets and dialogs and whenever I am changing any of their header files then the application takes 3-4 minutes to build. So if I use the forward declaration then will it decrease the build time?
Chandan
Simple example:
You have two header files a.h and b.h. b.h looks likeSo if you change something in a.h not only this needs to be recompiled, but also b.h. Otherwise (if you use forward declaration) only a.h needs to be recompiled. So yes, you can speed up compilation time.Qt Code:
#ifndef _B_H #define _B_H #include "a.h" class B { A* a; }; #endifTo copy to clipboard, switch view to plain text mode
Also, the compiler has not to include the header file here, which also saves some time, but that is not much...Qt Code:
#ifndef _B_H #define _B_H class A; class B { A* a; }; #endifTo copy to clipboard, switch view to plain text mode
Bookmarks