Results 1 to 7 of 7

Thread: Need definedInHeader("QString") == "q<somewhere>.h"

  1. #1
    Join Date
    Dec 2008
    Posts
    16
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Need definedInHeader("QString") == "q<somewhere>.h"

    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 ?

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need definedInHeader("QString") == "q<somewhere>.h"

    in Qt4:

    just
    #include <XXXXX>

    where XXXXX is the class name of the Qt-class.
    Qt Code:
    1. #include <QApplication>
    2. #include <QString>
    To copy to clipboard, switch view to plain text mode 
    etc.

  3. #3
    Join Date
    Dec 2008
    Posts
    16
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need definedInHeader("QString") == "q<somewhere>.h"

    What a neat trick - how indulgent !!! Is that also true for enums etc ..meaning any symbol that looks like "Q.*"

    ?

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need definedInHeader("QString") == "q<somewhere>.h"

    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).

  5. #5
    Join Date
    Dec 2008
    Posts
    16
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need definedInHeader("QString") == "q<somewhere>.h"

    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 ?

  6. #6
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need definedInHeader("QString") == "q<somewhere>.h"

    have your script iterate over Qt's include directory and grab the valid includes from there and generate only code for those

  7. The following user says thank you to caduel for this useful post:

    muenalan (29th September 2009)

  8. #7
    Join Date
    Dec 2008
    Posts
    16
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need definedInHeader("QString") == "q<somewhere>.h"

    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.


    Cheers,
    Thx^3 !

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.