title: Customizing shape of bounding rect
body: <p>I am drawing a line using mouse clicks. The line is drawn using paint function as: </p>
  
  <pre><code>painter-&gt;drawLine(start_p, end_p);
  </code></pre>
  
  <p>The bounding rect of line is defined as:</p>
  
  <pre><code>QRectF Line::boundingRect() const
  {
    // bounding rectangle for line
    return QRectF(start_p, end_p).normalized();
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/FX2mM.png" alt="enter image description here"></p>
  
  <p>This shows the line painted. I get the bounding rect for this as shown:</p>
  
  <p><img src="https://i.stack.imgur.com/JjE7p.png" alt="enter image description here"></p>
  
  <p>I want to have the bounding rect according to the shape of the item, something like:<img src="https://i.stack.imgur.com/ZAWDQ.png" alt="enter image description here"></p>
  
  <p>How to achieve this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>While selecting any of the overlapping lines, the one with bounding rect on top is selected(see figure below). Even making use of <code>setZValue</code> won't work here. 
  I want to implement this by minimizing the bounding rect to the shape of line.  </p>
  
  <p><img src="https://i.stack.imgur.com/AKxYT.png" alt="enter image description here"></p>