Results 1 to 4 of 4

Thread: Qt header files suggestion

  1. #1
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt header files suggestion

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qt header files suggestion

    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.
    Qt Code:
    1. #include <QtCore/QString>
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Lykurg for this useful post:

    chandan (1st March 2011)

  4. #3
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt header files suggestion

    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

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qt header files suggestion

    Simple example:
    You have two header files a.h and b.h. b.h looks like
    Qt Code:
    1. #ifndef _B_H
    2. #define _B_H
    3. #include "a.h"
    4. class B
    5. {
    6. A* a;
    7. };
    8. #endif
    To copy to clipboard, switch view to plain text mode 
    So 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:
    1. #ifndef _B_H
    2. #define _B_H
    3. class A;
    4. class B
    5. {
    6. A* a;
    7. };
    8. #endif
    To 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...

Similar Threads

  1. Qt Creator PROBLEM INCLUDING 'QSystemInfo' HEADER FILE
    By Rakula in forum Qt Tools
    Replies: 1
    Last Post: 24th September 2010, 09:28
  2. Replies: 2
    Last Post: 28th February 2010, 07:38
  3. Problem with including lib files
    By metow in forum Qt Tools
    Replies: 2
    Last Post: 12th December 2009, 21:57
  4. Replies: 1
    Last Post: 6th November 2009, 21:25
  5. qmake and including files doubt
    By clinisbut in forum Newbie
    Replies: 3
    Last Post: 16th August 2008, 15:40

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.