PDA

View Full Version : using QtGui



nupul
7th April 2006, 06:11
When and why should one use QtGui? I have seen that whenever a QDirModel or Qdir is being used the only file included is QtGui....why is this?

jpn
7th April 2006, 06:37
QtGui (http://doc.trolltech.com/4.1/qtgui.html) is a module containing GUI functionality.
It is for lazy people who want to add only one include which includes definitions of the whole module's classes instead of dozens of separate includes, one for each class.
The negative aspect is that you'll include a whole lot of unnecessary definitions..

nupul
7th April 2006, 07:06
agreed.......but even the Trolls have done the same in their doc...example of QdirModel.....do they come under the same category as you highlighted?

:D

Nupul

jpn
7th April 2006, 08:06
Ok, it doesn't really matter in an example of few lines. It may also be used for keeping an example simple, short and clear.. :)

jrideout
7th April 2006, 11:59
I find it useful to include QtGui rather than the individual headers whilst developing because I constantly add, remove, or change things in ways that break unexpectedly without the proper headers. After I stabilize the code I take out QtGui and add the proper include files. In headers I use class QSomething, as per the trolls advice in the docs, when I can.

wysota
7th April 2006, 12:36
It's ok to include "global" includes like QtGui when using precompiled headers. This boosts the precompiled header size but makes sure everything is included and the compilation remains very fast. When using QtGui inclusion in regular files (especially header files) compilation time increases significantly as the preprocessor has lots of more work to do.