Results 1 to 2 of 2

Thread: Proper way to #include Qt?

  1. #1
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Proper way to #include Qt?

    When I write Qt4 code, I just use the line
    #include <QtGui>
    in my header files to add basically everything I ever need. Then in my .cpp file I would just have
    #include "myheader.h"

    However, in the Qt examples, the header files often contain only a few specific #includes and then just the classes that are used in the header, like this:

    #include <QDialog>
    #include <QList>
    class QHBoxLayout;
    class QPushButton;

    Then in their .cpp file they have something like:
    #include <QtGui>
    #include "myheader.h"

    So my question is, why do they do it like this? It seems like a lot of extra lines of code for no advantage. Does it compile faster this way?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Proper way to #include Qt?

    Quote Originally Posted by pherthyl
    Does it compile faster this way?
    Potentially, since compiler doesn't have to read half of Qt headers.

Similar Threads

  1. QApplication: no such file or directory
    By jochen_r in forum Newbie
    Replies: 13
    Last Post: 15th November 2008, 21:46
  2. custom slot/signal
    By awnjoor in forum Newbie
    Replies: 17
    Last Post: 17th July 2006, 08:05
  3. Replies: 7
    Last Post: 2nd June 2006, 12:48
  4. use button from another Window
    By raphaelf in forum Qt Programming
    Replies: 11
    Last Post: 2nd March 2006, 20:31
  5. Replies: 18
    Last Post: 22nd February 2006, 20:51

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.