title: How to resize columns in QTreeWidget to the minimum space required
body: <p>I am a student programmer and I am using Qt to build a GUI interface for work. I have a <code>QTreeWidget</code> that has a total of 8 Columns. The input that needs to be entered into each one of these columns is fairly small. In that regard, I was trying to find a way to re-size all of the columns to the least amount of space required. much like the action that is performed when you click on the dividers. I have looked over several websites and the Qt documentation and haven't found a solution. After looking over the documentation it seems that there are a bunch of ways to do this but I cant get one to work. I am beginning to think that I need to enable/disable something somewhere. It's as if the changes I write in to my build function (This function clears the table; Reads data from my vector, displays certain data in the table, and then is suppose to re-size the headers/columns to just enough size to fit the contents of the column) are not even applied. I have tried the following with no changes:</p>
  
  <pre><code>        ui-&gt;treeWidgetInjections-&gt;setColumnWidth(i, minimumWidth());
          ui-&gt;treeWidgetInjections-&gt;resizeColumnToContents(i);
          ui-&gt;treeWidgetInjections-&gt;header()-&gt;ResizeToContents;
          ui-&gt;treeWidgetInjections-&gt;header()-&gt;resizeSection(i, minimumWidth());
  </code></pre>
  
  <p>All of these are in the end of of my build Function (unrelated info removed):</p>
  
  <pre><code>ui-&gt;treeWidgetInjections-&gt;clear();
      for (int i=0; i &lt; qTreeInjectionData.size(); i++)
          {
              //fill Qtree with items;
              //fill QTree items with data;
              //re size function here;
          }
  </code></pre>
  
  <p>Please only leave productive feedback as I am only interested in learning and overcoming this challenge. Thanks in advance!</p>