Search code examples
c++visual-studioqtvisual-studio-2012qtcore

Visual Studio recompiles "moc" files every time when running qmake


I'm having a quite large project which is developed in C/CPP with Qt. Every time i change a setting in the .pri or .pro file i have to convert the project with qmake.

I do this with:

qmake -spec win32-msvc2012 -tp vc $projectName.pro

after that i reload the project in Visual Studio (2012).

When i build the project every time ALL "moc" files are regenerated and the whole project compiles / rebuilds completely. Is there a method to just recompile the changed/new included files?


Solution

  • You should use the Visual Studio Add-In for Qt 5. There is one for Qt 4 as well, albeit the older version of that (1.1.11) does not support VS 2012. You can find the latest blog post about this in here:

    http://blog.qt.digia.com/blog/2013/04/11/visual-studio-add-in-1-2-1-for-qt-5-released/

    Among other things, you will get a lot more features than just what you write here. See this change log for the latest release:

    The Qt Visual Studio Add-In version 1.2.1 contains multiple bugfixes and improvements.

    Changes
    -------
    - Qt 5.0.1 help documents included
    - Qmake wrapper COM component removed and replaced with command line tool
      qmakefilereader to avoid need to load Qt5 library binaries to Visual Studio
      process. And to get installation of add-in easier, specially with VS2008.
    - Qt4 add-in is not allowed to run same time, if found it will be closed.
      Also if Qt4 add-in is present in system, default editor values for .ts, .ui
      and .qrc file types are not permanently overwritten by Qt5 add-in. Values are
      written when Qt5 add-in loads and Qt4 values are set when Qt5 add-in unloads.
      This should make it possible to install and use both Qt4 and Qt5 versions of
      add-in. Not to use same time but in turns. Though user must be careful what he
      does.
    - Recognizing Qt5 CE build. (QTVSADDINBUG-153)
    - Incorrect additional directories paths set when Qt modules added/removed from
      Qt Project Settings page. (QTVSADDINBUG-151)
    - Include directories search path for some Qt modules fixed (QTVSADDINBUG-150)
    - Invalid Qt module names fixed (QTVSADDINBUG-142)
    - Crash when importing .pri file fixed (QTVSADDINBUG-139)
    - Qt default settings saving problem fixed (QTVSADDINBUG-137)
    - Naming of precompiled header fixed (QTVSADDINBUG-132)
    - Support for debugger visualizers in VS2012 (QTVSADDINBUG-129)
    - Setting Qt libraries path for debugging session fixed (QTVSADDINBUG-125)