title: How to centralize the QTreeWidget header
body: <p>How to centralize the <code>QTreeWidget</code> header?</p>
  
  <p>I have the following <code>QTreeWidget</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/4oMUu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4oMUu.png" alt="enter image description here"></a></p>
  
  <p>And I want to centralize the header to look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/CrZx5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CrZx5.png" alt="enter image description here"></a></p>
  
  <p>I already tried to set this stylesheet:</p>
  
  <pre><code>QHeaderView::section {
       text-align: center;
   }
  </code></pre>
  
  <p>But it didn't work.</p>
  
  <p>I know that with <code>QTableWidget</code> we can do something like this:</p>
  
  <pre><code>myTableWidget-&gt;horizontalHeaderItem(0)-&gt;setTextAlignment(Qt::AlignCenter);
  </code></pre>
  
  <p>But <code>QTreeWidget</code> doesn't have horizontalHeaderItem().</p>
  
  <p>I'm on Qt 5.3.</p>