(I hadn't seen d_stranz's post before devising this work-around. See prior message. In any case -- THANKS SO MUCH for taking a look at this for us!)

To solve (or really, work-around) this problem, we modified qtbase\mkspecs\features\moc.prf

We first tried changing the name of the temporary include file mocinclude.tmp to mocinclude.opt (basically a patch that had been applied to Qt 5.6, I believe). That didn't help.

We then commented out the generation and use of that include path file, forcing -I arguments to moc.exe to all be put right on the command line invocation of that program (i.e. regardless of how many of those arguments there were). That worked for us.

Qt Code:
  1. # On Windows, put the includes into a .inc file which moc will read, if the project
  2. # has too many includes. We do this to overcome a command-line limit on Win < XP
  3. WIN_INCLUDETEMP=
  4.  
  5. # [Phil, 6-17-2016, skip the mocinclude file altogether]
  6. # win32:count(MOC_INCLUDEPATH, 40, >) {
  7. # WIN_INCLUDETEMP = $$MOC_DIR/mocinclude.opt
  8. #
  9. # WIN_INCLUDETEMP_CONT =
  10. # for (inc, MOC_INCLUDEPATH): \
  11. # WIN_INCLUDETEMP_CONT += -I$$inc
  12. # write_file($$absolute_path($$WIN_INCLUDETEMP, $$OUT_PWD), WIN_INCLUDETEMP_CONT)|error("Aborting.")
  13. # }
To copy to clipboard, switch view to plain text mode 
You must invoke qmake.exe on all Qt application project files after making this change to qtbase\mkspecs\features\moc.prf.

Notice that the original comment indicates that this mocinclude provision was introduced to address a command-line size limit on Windows versions before "XP". However, Qt Technical Support mentions to me that it would technically be possible to exceed the larger command line size limit of subsequent Windows versions, so it's not technically true that this mocinclude provision would never be needed.

We just couldn't get it to work for us. [Qt 5.5.1, Windows 8.1, Visual Studio 2010 Professional SP1]. The mocinclude.tmp (or .opt) file was absent (when we needed it to exist) when we attempted to build our application in Visual Studio. (See prior notes).