title: How to disable all widgets in MainWindow recursively
body: <p>It is easy to disable a widget in Qt using <code>-&gt;setEnable(false)</code> but if I have a lot of widgets, then the process is tedious and error-prone. I've searched for this issue and found out <code>findChildren()</code>. I would like to use it to disable all widgets in the windows. The following modified code is not working </p>
  
  <pre><code>for (auto widget : findChildren&lt;QMainWindow*&gt;())
        if (! qobject_cast&lt;QWidget*&gt;(widget)) widget-&gt;setEnabled(false);
  </code></pre>
  
  <p>How can I modify the preceding code to disable all widgets in my MainWindow Class?</p>