Does Qt's best practice include precompiled headers?

What is the current “best practice” regarding including Qt headers when using the latest and latest C ++ compiler (like MSVC2015) with precompiled headers?

Example:

#include <QStringList> 
#include <QTreeWidget>
#include <QListWidget>

against.

#include <QtCore>
#include <QtGui>
  • Which convention should I choose for a new project?

  • What are the advantages or disadvantages?

  • What is more common for new projects?

+4
source share
3 answers

As far as I know, there are no particular limitations / recommendations / advantages / disadvantages with Qt enabled and precompiled headers. When you include third-party header files (Qt or boost, or something else), the same rules apply.

(true Qt , , , , STL, ), . , . , , . , , , , / ( , ), , , , , ....

, , , . , QStringList, <QtCore/QStringList>, <QtCore>.

, , (.h), , (.cpp). ( ).

, , Qt , . . , ( ), , :

  • , . , ...
  • ( , , , ... , , , ).
+2

, , ,

#include <QtCore/QStringList>

,

#include <QtCore>

, QtCore, , , .

0

( ):

#pragma once

#ifdef QT_CORE_LIB
# include <QtCore>
#endif

#ifdef QT_CONCURRENT_LIB
# include <QtConcurrent>
#endif

#ifdef QT_GUI_LIB
# include <QtGui>
#endif

#ifdef QT_WIDGETS_LIB
# include <QtWidgets>
#endif

#ifdef QT_MULTIMEDIA_LIB
# include <QtMultimedia>
#endif

#ifdef QT_NETWORK_LIB
# include <QtNetwork>
#endif

#ifdef QT_XML_LIB
# include <QtXml>
#endif

#ifdef QT_QML_LIB
# include <QtQml>
#endif

#ifdef QT_QUICK_LIB
# include <QtQuick>
#endif

#ifdef QT_SQL_LIB
# include <QtSql>
#endif

#ifdef QT_PRINTSUPPORT_LIB
# include <QtPrintSupport>
#endif

It will contain the necessary definitions only when the module is connected. Works well with msvs + qt addin or with cmake based projects (I use cotire ).

0
source

Source: https://habr.com/ru/post/1687356/


All Articles