View Full Version : Need definedInHeader("QString") == "q<somewhere>.h"

28th September 2009, 14:04
I have a huge library of code which has messed up the include portions and now I want to do some scripting to guess the right includes (without including all, of course).

Is there a catalog map to find which header needs to be included to use a certain Qt class ?

something via moc ? or qt documentation system ?

28th September 2009, 14:17
in Qt4:

#include <XXXXX>

where XXXXX is the class name of the Qt-class.

#include <QApplication>
#include <QString>

28th September 2009, 14:29
What a neat trick - how indulgent !!! Is that also true for enums etc ..meaning any symbol that looks like "Q.*"


28th September 2009, 15:55
well, while theoretically the Trolls could do that for enums, too ... they have not.
You usually won't have to include separate headers for enums anyway as you typically will use some Qt class (that already includes the enum).

29th September 2009, 00:07
What a pitty, as my script just parses any symbols that appear Q* and tries to include the Q*.h file then. The code tree is really huge and fixing each file would be pain.

Any ideas to catalog enum's then ?

29th September 2009, 08:32
have your script iterate over Qt's include directory and grab the valid includes from there and generate only code for those

29th September 2009, 12:04
Yeah! Second thought: actually the enums in qt do not follow the Q* pattern ! Say

enum QGraphicsItem::GraphicsItemChange

Hmm, I think i'll try to exploit

int QMetaObject::indexOfEnumerator ( const char * name ) const
QMetaEnum QMetaObject::enumerator ( int index ) const

by including all Q* class includes, instantiating a dummy object and calling the enumerator() metaobject method.

Thx^3 !