title: How to specify -W4 (Visual Studio) in a Qt project?
body: <p>My environment:</p>
  
  <ul>
  <li>Windows 10, 64-bit</li>
  <li>Microsoft Visual Studio 2015</li>
  <li>Qt 5.6.2</li>
  <li>Qt Creator 4.8.1</li>
  </ul>
  
  <p>I want to compile my C++ project with <code>-W4</code> instead of the default <code>-W3</code>, so I added this line to my <code>.pro</code> file:</p>
  
  <pre><code>QMAKE_CXXFLAGS += -W4
  </code></pre>
  
  <p>But then, I get many of these warnings (one for each compilation unit, I suppose):</p>
  
  <pre><code>cl : Command line warning D9025 : overriding '/W4' with '/W3'
  </code></pre>
  
  <p>From the command line, I can see that the command line does include both <code>-W3</code> and <code>-W4</code> (in this order).</p>
  
  <p>So, my question: <strong>How can I swap the order of <code>-W3</code> and <code>-W4</code> (so <code>-W4</code> would take precedence over <code>-W3</code>)?</strong></p>
  
  <p>Note that <strong>this did not work</strong>: I tried to modify Qt's configuration file <code>C:\Qt\5.6.2\msvc2015_64\mkspecs\common\msvc-desktop.conf</code>, by changing the value of variable <code>QMAKE_CFLAGS_WARN_ON</code> from <code>-W3</code> to <code>-W4</code>, and not adding <code>-W4</code> to <code>QMAKE_CXXFLAGS</code> in my <code>.pro</code> file, but that caused many (thousands) of warnings being generated by libraries. I also tried to append <code>-W4</code> to <code>QMAKE_CXXFLAGS_WARN_ON</code> (instead of <code>QMAKE_CXXFLAGS</code>) in my <code>.pro</code> file, with the same result (thousands of warnings from libraries).</p>
  
  <p>Also note that if I add <code>-Wall</code> (instead of <code>-W4</code>) to <code>QMAKE_CXXFLAGS</code>, then:</p>
  
  <ul>
  <li>I do not get similar command line warnings (although <code>-Wall</code> is
  followed by <code>-W3</code> on the command line)</li>
  <li>I still get many warnings from libraries, but considerably less than
  with <code>-W3</code> changed to <code>-W4</code> in <code>msvc-desktop.conf</code> (or with <code>-W4</code> appended to
  <code>QMAKE_CXXFLAGS_WARN_ON</code> in my <code>.pro</code> file).</li>
  </ul>
  
  <p>I use qmake (through Qt Creator), so any solutions that would require editing the generated Visual Studio project files would be unacceptable.</p>